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

Re: Navigating XML Using Attributes

Subject: Re: Navigating XML Using Attributes
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 11 Feb 2003 22:20:33 +0000
using attributes in xsl
Hi James,

> To navigate the XML document, one must pull the Ids from element
> <LevelA3> and return to the <Account> level to find the <LevelA3>
> elements that reside in the document just below <Account>. Once the
> appropriate <LevelA3> element is found, the XSL must find its way to
> <LevelB2>, grab its Id, return to the top and find <LevelB2> below.
> This continues until the data contained in <LevelC1> is found. For
> example, the path to DataGamma is: Account/LevelA1/LevelA2/LevelA3
> Id="333"/LevelB1/LevelB2 Id="11"/LevelC1:DataGamma
>
> I assume I will have to use apply-templates again and again. What I
> don't know is how to remember all the Ids in LevelA3, and below, so
> I can find each of the cooresponding elements. Any suggestions?

I don't really understand the problem about *remembering* the Ids in
LevelA3. If you apply templates to all the LevelA3 elements then they
will all be processed. I'd have something like:

<xsl:template match="LevelA2">
  ...
  <xsl:apply-templates select="LevelA3" />
  ...
</xsl:template>

<xsl:template match="LevelA3">
  <xsl:variable name="id" select="@Id" />
  <xsl:apply-templates select="/Account/LevelA3[@Id = $id]" />
</xsl:template>

<xsl:template match="LevelA3[node()]">
  ...
</xsl:template>

I would also consider using a key to index the elements under the
Account element by their Id attributes (and possibly by their name) so
that you can access them quickly.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.