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

Re: Creating a padded sort key: easier from elt sequen

Subject: Re: Creating a padded sort key: easier from elt sequence or string?
From: Yves Forkl <Y.Forkl@xxxxxx>
Date: Wed, 26 Jul 2006 10:59:10 +0200
sketch elt
I would like to say Thank you to darkman, David Carlisle and Michael Kay for your precious comments.

drkm> >> [Which one of two representations of "3.11.A.9" is
drkm> >> easier to turn into a padded sort key? 1) a string]
drkm> >>
drkm> >> 2) an element containing a sequence of PCDATA elements,
drkm> >> one for each of the numbers and letters (the dot in
drkm> >> between may be added during processing)
drkm>
drkm>
drkm>   With that, you can simply use several xsl:sort.

So I'll try with the second approach. (As I am currently not using
Saxon, I don't want to depend on its built-in collation options for
the moment.)

I suppose indicating multiple sort keys would yield something like
this in the case of "3.11.A.9", when each of the numbers and letters is marked up as sort_key_elt:


<xsl:for-each select="$my_nodeset_to_sort">
  <xsl:sort select="/path_to_dotted_sequence_elt/sort_key_elt[1]"
    data-type="number"/>
  <xsl:sort select="/path_to_dotted_sequence_elt/sort_key_elt[3]"
    data-type="number"/>
  <xsl:sort select="/path_to_dotted_sequence_elt/sort_key_elt[2]"
    data-type="text"/>
  <xsl:sort select="/path_to_dotted_sequence_elt/sort_key_elt[4]"
    data-type="number"/>
</xsl:for-each>

However, I face two problems:

- As my dotted sequence can be of variable length, I need to determine
  the number of sort statements dynamically. Maybe by using recursion?
  (How to modify the lines above in order to avoid undesired changes
  of the context node when calling the recursion template)?

- The position of the numbers and letters in the sequence can also
  vary. While Jeni Tennison recommends simply using a variable to set
  the value of attribute data-type dynamically (in "XSLT and XPath On
  The Edge", p. 157), I can't see how this could combine with the
  first problem, i.e. dynamic selection of the number of sort keys,
  into a sensible thing.

What might a sketch of a template for sorting based on the sort key in
the element sequence look like?

Or is it better to concatenate the padded contents of all sort_key_elt
elements into a string to be used as a single sort key of type "text"?

Yves

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.