|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Recursing on top-level elements
Hi,
How can I recurse on top-level context elements while doing a for-each loop
further down the structure?
Example XML:
<test>
<foo id=1/>
<foo id=3/>
<bar>
<baz id=1/>
<baz id=2/>
<baz id=3/>
<baz id=4/>
</bar>
</test>
Now, while in my for-each on /test/bar/baz, I want to do something if the id
attribute on a baz element exists in any of the foo elements. My XSL now
looks like this:
<xsl:template match="/">
<xsl:for-each select="test/bar/baz">
<xsl:choose>
<xsl:when test=".[@id = /test/foo/@id]">
<!-- Do something -->
</xsl:when>
<xsl:otherwise>
<!-- Do something else -->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
This works for baz elements that have the same id as the first foo element
(id=1), but not for the baz with id=3.
Suggestions anyone?
/Jan
***************************************************
Jan Thunqvist
e-mail: jan.thunqvist@xxxxxxxxxxx
Technia AB
Box 1141
S-164 22 KISTA, Sweden
Tel: +46-(0)8-477 24 00
Fax: +46-(0)8-477 24 24
WWW: http://www.technia.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








