[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Problem in XSL transformation

Subject: Re: Problem in XSL transformation
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 6 Sep 2006 09:48:26 +0100
xsl firstchild
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.