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

Re: Sorting using helper structure, position(), xsl:ke

Subject: Re: Sorting using helper structure, position(), xsl:key
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 10 Apr 2008 14:17:52 +0100
Re:  Sorting using helper structure
> First question: Is it possible, in XSLT 1.0, to sort my items
> based on a helper structure like the following,

yes

if $cat stores <Categories) then 

<xsl:sort
select="count($cat/Cat[.=current()/@cat]/preceding-sibling::Cat)"

$cat neets to be a node set (of one node) not an RTF so you need to put
the maping in a source file, perhaps loaded by document() or if you put
it into a RTF variable in the stylesheet use an x;node-set() extension
to make it into a node set. Or use xslt2 where this RTF nonsense goes
away.

> Finally, for a huge set of categories, I'd want to use an
> xsl:key. How would that fit into the picture? Is it possible
> to have the key return the context position? Or would this be
> difficult as maybe there is no context when an xsl:key is
> built?

in xslt2 you koul just use <xsl:sort select="key('cat',@cat,$cat)" with
the new 3rd argument telling teh system which document to use for the
key, but in xslt1 you have to be in the right document already, which
means that in teh restricted context of xsl:sort you can only use a key
if your mappig element is in teh same document as the nodes over which
you are iterating.

Davud

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.