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

Re: Sorting problems [was: Choosing different sorts]

Subject: Re: Sorting problems [was: Choosing different sorts]
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 16 Jul 2004 12:16:23 +0100
string sml
      <xsl:for-each select="file">
        <xsl:sort select="*[name(.) = $sortkey]"/>   

That means that your sort key is determined by selecting a child element
of file (that's what * means) whose name is equal to the string value of
$sortkey.

but for example if $sort='design' then $sortkey is (a result tree
fragment with text node the) string 'sml:meta/sml:designer/sml:name'

and there is no child element with name that string (it isn't a legal
XML+namespace eleemt name as it's got "/" in it and more than one ":" ).

You don't want to sort on child elements of file at all you presumably
want to sort on the element with Xpath sml:meta/sml:designer/sml:name
relative to file. But there is a big difference between the string
'sml:meta/sml:designer/sml:name' and an Xpath, and no easy way in xslt
to go from one to the other, just as in C or Java (or most other
languages) it's hard to go from the string "x + 1" to incrementing the
variable x by 1, you have to write (or find) a parser for the language to
interpret the string.

You presumably want something like


     <xsl:for-each select="file">
        <xsl:sort
        select="sml:scenario[$sort!='design'][$sort!='stat']/sml:name
              | sml:meta[$sort='design']/sml:designer/sml:name
              | sml:scenario[$sort='stat']/@status"/>

Note here I have only used XPaths, not strings or equivalently element
content.

This is a FAQ...

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.