[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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=", "/> 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 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 3: 3: 2007-10-22, 2007-10-23, 2007-10-24 t:\ftemp>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|