[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] update value of variable in for-each loop


Subject: Re: [xsl] update value of variable in for-each loop
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 08 Apr 2014 21:51:49 +0100

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