xsl-list
[Top] [All Lists]

Correct use of Parameters?

2002-09-04 13:32:35
Hello all:

I'm using 2 parameters (probably could have used xsl:variables...) to store
values that are referenced more than once while performing XSLT. My question
is: Is this more efficient (better practice) than walking the nodes each
time? I've included the xml and the pertinent xsl statements.

Thanks,
-Will

************** XML ***********************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet  type="text/xsl" href="../xsl/routecodemaintlookup.xsl" ?>
<RouteCodeMaintLookup
   servletPath="test">
   <SearchCriteria
     businessEntityName="LIBERTY MUTUAL" 
     routeCode="RC1"
     userID="xzs3h2"/>
   <RouteCodeList 
     listComplete="N"
     numberOfItems="1">     
     <RouteCodeItem 
       lineNumber="1"
       objectID="0:0:0:1"
       routeCodeID="RC1"
       routeCodeDescription="RC1 Description XXXX">
       <Team 
             objectID="0:0:0:2"
             teamID="TM1"
                 teamName="Team1">
             <BusinessUnit
               objectID="0:0:0:3"
                   businessUnitID="BU1"
                   businessUnitName="Biz Unit 1">
                 </BusinessUnit>
           </Team>
         </RouteCodeItem>
   </RouteCodeList>
</RouteCodeMaintLookup>

******************** XSL ************************************
[snip]
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.1">
<xsl:param name="userID"
select="/RouteCodeMaintLookup/SearchCriteria/@userID"/>
<xsl:param name="businessEntityName"
select="/RouteCodeMaintLookup/SearchCriteria/@businessEntityName"/>
<xsl:output method="html" doctype-public="-//W3C//DTD HTML 4.0//EN" />


[snip]
<xsl:template match="/">
.
.
</
<xsl:template match="RouteCodeMaintLookup">
.
.
</
<xsl:template match="SearchCriteria">
.
.  
      <TD VALIGN="MIDDLE" ALIGN="LEFT">
         <FONT SIZE="2">
           <NOBR>
            <xsl:value-of select="$businessEntityName"/>  
           </NOBR>
          </FONT>
      </TD>
.
.
        <INPUT ID="BusinessEntity" TYPE="HIDDEN" NAME="hfBusinessEntity">
             <xsl:attribute name="value"><xsl:value-of
select="$businessEntityName"/></xsl:attribute>
.
.
        <INPUT ID="userID" TYPE="TEXT" NAME="txtUserID"  SIZE="8"
MAXLENGTH="8" TABINDEX="1">
                <xsl:attribute name="value"><xsl:value-of
select="$userID"/></xsl:attribute>
             </INPUT>

One more thing...Is there a better way to write this?
<xsl:value-of
select="/RouteCodeMaintLookup/RouteCodeList/RouteCodeItem/Team/BusinessUnit/
@businessUnitName"/> 

Looking at the XML, all the BusinessUnit info is in the next node- what I
mean by better is shorter...a more compact version.

TIA

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>