[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem in XSL transformation
The scope of a variable binding is teh element in which it's contained so here: <xsl:variable name="inputSymbol" select="substring-after($inputSymbol,'|')"/> $inputSymbol ha steh new definition for the rest of this iteration of the body of the for-each but at the end of that iteration it will resume its original value. In writing it in this way you are asuming that a for-each will be executed in a particular order, but that is not teh case, a for-each specifies a body of code to be executed for each item in a sequence, but they may be executed in any order, and in particular in parallel. This is why declarative languages aim to be "side effect free" so that the result of execution is not changed if code is executed in a different order. instead of using for-each, apply templates to root/firstChild[1] and then have the template for each child apply templates to following-sibling::*[1], passing on the new value of the string parameter as a xsl:param. Or, if you are using xslt2, first tokenise the string then just use the string for this position directly: <xsl:variable name="strings" select="tokenize($str,'|')"/> <xsl:for-each select="root/firstChild"> <xsl:variable name="p" select="position()"/> ...<xsl:value-of select="$strings[min($p,last())]"/>... David
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! 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
|