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

Re: sequence numbering.

Subject: Re: sequence numbering.
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 2 Apr 2002 19:14:07 +0100
find a color sequence
Hi William,

> Here i was adviced by Jenni to sort the colors and store it in
> Variable.. and then use the <xalan:nodeset > for processing. in
> doing so when i try to use the <xsl:key>, it does not seem to give
> me the desired result.

When you use a key with the key() function, the processor only
searches the document that the current node is in. In your code, the
current node when you use the key is a product element from the new
node tree that you create. This new node tree doesn't contain any
colorlist element, so the key doesn't find any color elements that are
children of a colorlist element, so it doesn't return anything.

The simplest solution, I think, is to copy the colorlist into the new
$sorted-color node tree that you create at the same time as you create
the sorted list of products. So create $sorted-color with:

  <xsl:variable name="sorted-color">
    <xsl:for-each select="products/product">
      <xsl:sort select="color" data-type="text" order="descending"/>
      <xsl:copy-of select="."/>
    </xsl:for-each>
    <xsl:copy-of select="products/colorlist" />
  </xsl:variable>

and leave the rest of the code as it is.

The other option would be to store the root node of the original
document in a variable, then use an xsl:for-each to swap back out to
that document, and use the key within that xsl:for-each, but that's
more complicated.
  
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.