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

Re: Sort problem

Subject: Re: Sort problem
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Mon, 5 Feb 2001 04:31:12 -0800 (PST)
sort words
OK,

This will work only if your hyphenation character comes before any
other characters in the words.

One example is to use"~" instead of "-".

Interestingly enough, MSXML3 sorts "-" before the alphabetical
characters and "~" after them.

With MSXML3 and the stylesheet I supplied and the following xml source:

<root>
	<line lineID="1">
		<word wordID="1">ABC-</word>
		<word wordID="2">ABCD</word>
		<word wordID="2">ABCDE</word>
	</line>
	<line lineID="2">
		<word wordID="1" type="end">DEF</word>
		<word wordID="2">XYZ</word>
	</line>
</root>

I get the following result:

ABCD
ABCDE
ABCDEF
XYZ


With Saxon I get:

ABCDEF
ABCD
ABCDE
XYZ

This must be definitely a bug in MSXML3.

Dimitre.
--- Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> Hi Mick,
> 
> Use:
> 
> <xsl:for-each select="root/line/word[not(@type = 'end')]">
>   <xsl:sort
>
select="concat(.,self::*[contains(.,'-')]/following::word[@type='end'])"/>
>   <xsl:choose>
>     <xsl:when test="contains(., '-')">
>       <xsl:value-of select="substring-before(., '-')"/>
>       <xsl:value-of select="following::word[@type='end']"/>
>     </xsl:when>
>     <xsl:otherwise>
>       <xsl:value-of select="."/>
>     </xsl:otherwise>
>   </xsl:choose>
>   <xsl:if test="position() != last()">
>     <xsl:text>
</xsl:text>
>   </xsl:if>
> </xsl:for-each>
> 
> 
> Cheers,
> Dimitre Novatchev.
> 
> Mick <mick at telekabel dot nl> wrote:
> 
> Hi all,
> 
> I have the following problem when sorting a list of words. My xml is:
> 
> <root>
> 	<line lineID="1">
> 		<word wordID="1">ABC-</word>
> 		<word wordID="2">ABCD</word>
> 	</line>
> 	<line lineID="2">
> 		<word wordID="1" type="end">DEF</word>
> 		<word wordID="2">XYZ</word>
> 	</line>
> </root>
> 
> I have a stylesheet to create an alphabetical list of words. If a
> word
> contains a dash, it means it has to be joined with the following word
> that
> has an attribute type="end". The xsl I use is:
> 
> <xsl:for-each select="root/line/word">
> <xsl:sort select="."/>
> 	<xsl:choose>
> 		<xsl:when test="contains(., '-')">
> 			<xsl:value-of select="substring-before(., '-')"/>
> 			<xsl:value-of select="following::word[@type='end']"/><br/>
> 		</xsl:when>
> 		<xsl:when test="@type='end'"></xsl:when>
> 		<xsl:otherwise>
> 			<xsl:value-of select="."/>
> 		</xsl:otherwise>
> 	</xsl:choose>
> </xsl:for-each>
> 
> The result is:
> 
> ABCDEF
> ABCD
> XYZ
> 
> which is not what I want because the alphabetical order is wrong. The
> xsl:sort only sorts on the 'substring-before' part ABC minus the
> dash)
> and
> ignores the 'following::word' bit (DEF). I want the output to be:
> 
> ABCD
> ABCDEF
> XYZ
> 
> How can I get the result of the 'substring-before' part and the
> 'following::word' part to be handled as one entity?
> I'm using IE and MSXML3.
> 
> -mick
> 
> 
> 
> 
> __________________________________________________
> Get personalized email addresses from Yahoo! Mail - only $35 
> a year!  http://personal.mail.yahoo.com/
> 


__________________________________________________
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Sort problem
    • Mick - Mon, 5 Feb 2001 05:56:25 -0500 (EST)
      • <Possible follow-ups>
      • Dimitre Novatchev - Mon, 5 Feb 2001 06:49:21 -0500 (EST)
      • Dimitre Novatchev - Mon, 5 Feb 2001 07:31:23 -0500 (EST) <=
      • Dimitre Novatchev - Mon, 5 Feb 2001 07:54:13 -0500 (EST)
        • Mick - Mon, 5 Feb 2001 08:54:25 -0500 (EST)
        • Jeni Tennison - Mon, 5 Feb 2001 10:44:42 -0500 (EST)

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.