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

Re: Sort problem

Subject: Re: Sort problem
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 5 Feb 2001 14:58:39 +0000
xsl sort i18n
Hi Mick,

Dimitre wrote:
> The xsl:sort element in the previous stylesheet must be modified to the
> following:
>
> <xsl:sort 
> select="translate(concat(.,self::*[contains(.,'')]
                                                ^^
> /following::word[@type='end']), '-', '')"/>

but meant:

<xsl:sort
select="translate(concat(.,self::*[contains(.,'-')]
                                              ^^^
/following::word[@type='end']), '-', '')" />

Brilliantly insightful solution.

Just to explain why the stuff I wrote used lots of substring() and
string-length() all over the place: I was assuming that there might be
words that contained hyphens in the middle of them.  For example:

  <word>ABC-</word>
  <word>spirit-level</word>
  <word type="end">DEF</word>

should presumably be output/sorted as:

  ABCDEF
  spirit-level

rather than:

  ABCDEF
  spiritDEF

Of course it might not be a problem with the input that you're using,
but if it is, then you need to substitute:

  contains(., '-')      -> substring(., string-length()) = '-'
  string-before(., '-') -> substring(., 1, string-length() - 1)

and of course using the translate() function will get rid of *all* the
hyphens in the words, which may or may not be helpful. The safest
solution is probably:

concat(substring(., 1, string-length() - 1),
       substring(self::node()[substring(., string-length()) != '-'],
                 string-length()),
       self::node()[substring(., string-length()) = '-']
          /following::word[@type = 'end'])

But of course you should use the simplest that you can get away with.

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.