xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Three questions on sorting..


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

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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor