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

Recursing on top-level elements

Subject: Recursing on top-level elements
From: "Jan Thunqvist" <jan.thunqvist@xxxxxxxxxxx>
Date: Thu, 30 Mar 2000 09:36:07 +0200
thunqvist
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


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.