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

Re: Three questions on sorting..

Subject: Re: Three questions on sorting..
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 20 Jun 2001 17:10:28 +0100
Re:  Three questions on sorting..
Hi Tim,

> Got sorting by a varibale going, easy with Mike's example. I've had
> a good look throught the FAQ's again but nothing similar to the sort
> by external elements. I copied Mike's other example and changed it a
> bit:
>
> ......snip......
> <xsl:variable name="manExt" select="document('manufacturers.xml')"/>
> ..................
> <xsl:when test="$orderBy='manufacturer'">
>         <xsl:for-each select="car">     
>         <xsl:variable name="manId"><xsl:value-of select="normalize-space
> (manufacturer)"/></xsl:variable>
>         <xsl:sort select="$manExt/manufacturers/manufacturer
> [@ID=$manId]/name"/>
[snip]

The xsl:sort has to be the first child of the xsl:for-each - you can't
set a variable before it.  However, you can access the manufacturer of
the car that you want to sort using the current() function to get the
current node (the node that the XSLT is processing rather than the
node that you're looking at within the XPath).  So try:

  <xsl:for-each select="car">
     <xsl:sort select="$manExt/manufacturers
                          /manufacturer[@ID = current()/manufacturer]
                          /name" />
     ...
  </xsl:for-each>

I hope that helps,

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.