|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Document function (was Getting an error with a va
> This is a snippet of code. Am I on the right > track or is there a more efficient way? > > <xsl:for-each > select="/legs/competition/leg/Competitor[../../@name=$paramVal1]"> > <tr> > <td><xsl:value-of select="@no"/></td> > <xsl:variable name="cNum"> > <xsl:value-of select="@no"/> > </xsl:variable> Never do this. Write <xsl:variable name="cNum" select="@no"/> There's no need to construct a new result tree fragment when you only want a reference to a node. (And no need for three lines of code when one would do - XSLT is verbose enough without making it worse). > <td><xsl:value-of > select="document('EntryList.xml')/entrylist/competition/entry/ > @driverSurname > [../@no=$cNum]"/> > <td><xsl:value-of > select="document('EntryList.xml')/entrylist/competition/entry/ > @coDriverSurna > me[../@no=$cNum]"/> You're less reliant on the optimizer if you define a variable: <xsl:variable name="entry" select="document('EntryList.xml')/entrylist/competition/entry[@no=$cNum]"/> then select="$entry/@driverSurname" and select="$entry/@codriverSurname" Note also, predicates can appear on steps in a path expression other than the last. You can write document('EntryList.xml')/entrylist/competition/entry[@no=$cNum]/@driverSurn ame Michael Kay http://www.saxonica.com/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|







