[Home] [By Thread] [By Date] [Recent Entries]
Thanks Martin,
I believe I am using the free version of Saxon 9 (but did not know how to obtain the version number directly) called in a windows batch file with the command : java -jar c:\Users\HP\saxon\saxon9.jar xml\all-themes.xml xslt\get-dates.xsl > work\dates.xml The template, a selection of the input file, and the corresponding selection from the output file appear below. Thanks, Mark Again, my template is: <xsl:template match="List"> <xsl:element name="List"> <xsl:for-each-group select="Item/Stamp" group-by="concat(Date/@year, ' ', Date/@month, ' ', Date/@day)"> <xsl:sort select="Date/@year" data-type="number"></xsl:sort> <xsl:sort select="Date/@month" data-type="number"></xsl:sort> <xsl:sort select="Date/@day" data-type="number"></xsl:sort> <xsl:sort select="@value" order="descending" data-type="number"></xsl:sort> <xsl:element name="Item"> <xsl:copy-of select="current()/Date" copy-namespaces="no"></xsl:copy-of> <xsl:copy-of select="current-group()" copy-namespaces="no"></xsl:copy-of> </xsl:element> </xsl:for-each-group> </xsl:element> </xsl:template> A suitable selection of the input file [edited to remove <Stamp>'s numerous sibling elements not involved in this process]: <List> <Item> <Stamp scott-number="2888" pofis-number="12" value="1" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CeskC) Budejovice" eng="Ceske Budejovice"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2889" pofis-number="13" value="2" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CstC- nad Labem" eng="Usti nad Labem"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2890" pofis-number="14" value="3" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CeskC= Crumlov" eng="Cesky Crumlov"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2892" pofis-number="15" value="5" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="PlzeE" eng="Pilzen"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2895" pofis-number="16" value="8" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Olomouc" eng="Olomouc"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2896" pofis-number="17" value="10" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Hradec KrC!lovC)" eng="Hradec Kralove"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2897" pofis-number="18" value="20" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Praha" eng="Prague"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <Item> <Stamp scott-number="2898" pofis-number="19" value="50" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Opava" eng="Opava"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> </List> The complete output for the sample input. My output is not in descending according to the value attribute: <List> <Item> <Date year="1993" month="7" day="1"></Date> <Stamp scott-number="2888" pofis-number="12" value="1" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CeskC) Budejovice" eng="Ceske Budejovice"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2889" pofis-number="13" value="2" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CstC- nad Labem" eng="Usti nad Labem"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2890" pofis-number="14" value="3" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="CeskC= Crumlov" eng="Cesky Crumlov"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2892" pofis-number="15" value="5" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="PlzeE" eng="Pilzen"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2895" pofis-number="16" value="8" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Olomouc" eng="Olomouc"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2896" pofis-number="17" value="10" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Hradec KrC!lovC)" eng="Hradec Kralove"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2897" pofis-number="18" value="20" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Praha" eng="Prague"></Inscription> <Theme>Cities</Theme> </Stamp> <Stamp scott-number="2898" pofis-number="19" value="50" type="definitive"> <Date year="1993" month="7" day="1"></Date> <Inscription czech="Opava" eng="Opava"></Inscription> <Theme>Cities</Theme> </Stamp> </Item> <List> -----Original Message----- From: Martin Honnen Sent: Wednesday, July 27, 2011 10:40 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Sorting seems not to work completely Mark wrote: I cannot get the @value to sort in descending order. My XML (simplified) and template are below. The sorts on the Date attributes work, but the one on the value attribute does not. Please, what am I doing wrong?
-- Martin Honnen --- MVP Data Platform Development http://msmvps.com/blogs/martin_honnen/
|

Cart



