[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 21:51:49 +0100
Re:  update  value of variable in for-each loop
On 08/04/2014 21:18, henry human wrote:
sorry Michael, David
I was little bustling!
  hope this below is more clear now.
The varable value should be updated



<xsl:variable name="foo"/>

This variable isn't used.



  <xsl:for-each select=bpartiotion/files/file[@name=bxxb or name=bxyb or name=basdb or  b&b&b&.. b>
        <xsl:variable name="foo">
                      <xsl:for-each select="data">
                          <xsl:choose>
                              <xsl:when test="contains(elements/elementA '1234) or contains(elements/package/id '55) or contains(elements/category/id, '67)" or contains(b&b&b&b&.">

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

This variable is only used once, on the line below so really no point in havin it, as mentioned before $foo will be a document node with a text node child that is a sequence of 0 and 1.



<xsl:choose> <xsl:when test="$foo = 1">

So it will only be equal to 1 if all but the last value in the loop above gave 1 ir if $foo is 0000000000000000000001 But it seems a pretty strange thing to be testing.

//doSomething </xsl:when> <xsl:otherwise> //doNothing </xsl:otherwise> </xsl:choose> </xsl:for-each


As a wild guess, perhaps you didn't want any variable at all and wanted all of the above replaced by


<xsl:if test="(partiotion/files/file[@name=bxxb or name=bxyb or name=basdb or b&b&b&.. )/
data/(contains(elements/elementA '1234) or contains(elements/package/id '55) or contains(elements/category/id, '67)" or contains(b&b&b&b&.))">
do something
</xsl:if>



David


--
google plus: https:/profiles.google.com/d.p.carlisle

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.