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

Re: update value of variable in for-each loop

Subject: Re: update value of variable in for-each loop
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 08 Apr 2014 20:56:18 +0100
Re:  update  value of variable in for-each loop
On 08/04/2014 20:13, henry human wrote:
Hi
I have a for-each loop
inside for-each I try to test a variable:

Sorry, I can't work out what your question is. Your code fragments below dont't have an xsl:if aand you gove no indication what you intend then to produce. (It is very hard to guess as they are so convoluted.


//if statement
  <xsl:if test="$foo = 1">
  //do nothing



  The varibale definition:
  	<xsl:variable name="foo"/>
That defines foo to be an empty string, butit doesn't matter what it defines it to be as you immediately discard this variable and over-write it with another one with the same name:
  		<xsl:variable name="foo">
					<xsl:for-each select="data">
						<xsl:choose>
							<xsl:when test="contains(elements/elementA '1234)">

								<xsl:value-of select="1"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="0"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</xsl:variable>
				

that defines $foo to be a document node with a sing;e text node child that is a sequence of 1s and 0s.


				
				
Unfortunatelly the value of the varable foo is either 001 , 011,00011 and so one

That is what I'd expect, but yu don't say what you want it to be.



and the if statement works never correct !


There is no if?

I even defined the varable as a xs:integer type or as below , but ever the value is never a 1 or 0

<xsl:variable name="foo"  select='1'"/>
  		<xsl:variable name="foo">
					<xsl:for-each select="data">
						<xsl:choose>
							<xsl:when test="contains(elements/elementA, '1234)">

								<xsl:value-of select="'1'"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="'0'"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
				</xsl:variable>
				
Brg
Henry

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.