sorry Michael, David
I was little bustling!
hope this below is more clear now.
The varable value should be updated
<xsl:variable name="foo"/>
<xsl:for-each select=”partiotion/files/file[@name=’xx’ or name=’xy’ or
name=’asd’ or ……….. ”>
<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(………….">
<xsl:value-of select="1"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="$foo = 1">
//doSomething
</xsl:when>
<xsl:otherwise>
//doNothing
</xsl:otherwise>
</xsl:choose>
</xsl:for-each
--------------------------------------------
Michael Kay <mike(_at_)saxonica(_dot_)com> schrieb am Di, 8.4.2014:
Betreff: Re: [xsl] update value of variable in for-each loop
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Datum: Dienstag, 8. April, 2014 21:56 Uhr
What are you actually
trying to achieve? If you simply want to test whether one of
the elementA elements contains "1234", you can
write
<xsl:if
test="elements/elementA[contains(.,
'1234')]">
...
</xsl:if>
But I can't tell if that's what you are
trying to do because you don't say. You've been
using this list long enough to know that most of us have
difficulty reverse-engineering requirements from non-working
code.
Michael Kay
Saxonica
On 8
Apr 2014, at 20:13, henry human <henry_human(_at_)yahoo(_dot_)de>
wrote:
Hi
I have a for-each loop
inside for-each I try to test a
variable:
//if statement
<xsl:if test="$foo =
1">
//do nothing
The varibale
definition:
<xsl:variable
name="foo"/>
<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>
Unfortunatelly the value
of the varable foo is either 001 , 011,00011 and so one and
the if statement works never correct !
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--