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

Re: Grouping hierarchy path elements, part 2

Subject: Re: Grouping hierarchy path elements, part 2
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 24 Aug 2004 10:33:31 +0100
hierarchy key
Hi Daniel,

> It seems as if there is something wrong with my items parameter for
> the transformDocument template called from the template 'otherItem'.
> If you run the above, you will notice that <xsl:value-of select="
> //item[attribute::id]"/> actually does not return the id-Attribute
> element of all items, but instead returns the child elements of the
> first referenced item. Finding a solution to this would get me a big
> step ahead I think.

You're currently using:

  //item[attribute::id = referenceItemId]

This selects those <item> elements whose id attribute is equal to the
value of a <referenceItemId> element *within that <item> element*. You
want to select the <item> elements whose id attribute is equal to the
value of a <referenceItemId> element *within the current <otherItem>
element*. To do this, you can use:

  //item[@id = current()/referenceItemId]

though personally, I would define a key to index the <item> elements
by their id:

<xsl:key name="items" match="item" use="@id" />

and then use the key() function to retrieve the relevant items:

  key('items', referenceItemId)

as this is more efficient.

Note that you should also use the items for the particular <otherItem>
when identifying the name of the root folder. I suggest changing the
template for <otherItem> elements to:

<xsl:template match="otherItem">
  <Chapter id="{@id}">
    <xsl:variable name="items" select="key('items', referenceItemId)" />
    <xsl:variable name="root" select="substring-before($items[1]/path, '\')"/>
    <path name="{$root}">
      <xsl:call-template name="transformDocument">
        <xsl:with-param name="path" select="$root"/>
        <xsl:with-param name="items" select="$items"/>
      </xsl:call-template>
    </path>
  </Chapter>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

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.