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

Re: xsl:perform-sort sequence problem

Subject: Re: xsl:perform-sort sequence problem
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 22 Oct 2007 08:08:39 -0400
Re:  xsl:perform-sort sequence problem
At 2007-10-22 13:05 +0200, Merico Raffaele wrote:
I am using SaxonB 8.9 and I have the following xsl:perform-sort/sequence
problem.

Actually your problem is elsewhere.


When I try to sort the same sequence the distinct-values become one single
string:

Actually, your distinct-values is still a sequence ... but your variable is a temporary tree:


<xsl:variable name="result">
        <xsl:perform-sort select="distinct-values($data/item/departure[@date
eq '2007-10-22']/returning/@date)">
                <xsl:sort/>
        </xsl:perform-sort>
</xsl:variable>
<xsl:value-of select="count($result)"/>

And above you are counting your temporary trees.


<xsl:value-of select="$result" separator=", "/>

=> 1
=> 2007-10-22 2007-10-23 2007-10-24

Can any body please helping me to clarify my misunderstanding of the
xsl:perform-sort.

You need to better understand your variable declarations.


Instead of a temporary tree, you want a variable of strings. Therefore, declare your variable with:

as="xsd:string+"

I hope the working answer below helps.

. . . . . . . . . . . Ken

t:\ftemp>type merico.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xsd"
                version="2.0">

<xsl:output method="text"/>

<xsl:template match="/">
<xsl:variable name="data">
        <item id="1">
                <departure date="2007-10-22">
                        <returning date="2007-10-23"/>
                        <returning date="2007-10-24"/>
                </departure>
        </item>
        <item id="2">
                <departure date="2007-10-22">
                        <returning date="2007-10-22"/>
                        <returning date="2007-10-24"/>
                </departure>
        </item>
</xsl:variable>

Result 1:
<xsl:variable name="result1"
select="distinct-values($data/item/departure[@date eq
'2007-10-22']/returning/@date)"/>
<xsl:value-of select="count($result1)"/>: <xsl:text/>
<xsl:value-of select="$result1" separator=", "/>


Result 2: <xsl:variable name="result2"> <xsl:perform-sort select="distinct-values($data/item/departure[@date eq '2007-10-22']/returning/@date)"> <xsl:sort/> </xsl:perform-sort> </xsl:variable> <xsl:value-of select="count($result2)"/>: <xsl:text/> <xsl:value-of select="$result2" separator=", "/>

Result 3:
<xsl:variable name="result3" as="xsd:string+">
        <xsl:perform-sort select="distinct-values($data/item/departure[@date
eq '2007-10-22']/returning/@date)">
                <xsl:sort/>
        </xsl:perform-sort>
</xsl:variable>
<xsl:value-of select="count($result3)"/>: <xsl:text/>
<xsl:value-of select="$result3" separator=", "/>


</xsl:template>


</xsl:stylesheet>
t:\ftemp>xslt2 merico.xsl merico.xsl con


Result 1: 3: 2007-10-23, 2007-10-24, 2007-10-22


Result 2: 1: 2007-10-22 2007-10-23 2007-10-24

Result 3:
3: 2007-10-22, 2007-10-23, 2007-10-24
t:\ftemp>


-- Comprehensive in-depth XSLT2/XSL-FO1.1 classes: Austin TX,Jan-2008 World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Jul'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

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.