|
Subject: Re: [xsl] Tokenized String Sorting Puzzle/Problem From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 26 Mar 2008 13:40:06 GMT |
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="s" select="'1 0 2 1 1 2 1 3 1 4 2 0 1 1 2 3 2 4 6 0 5 0 10 0 10 1 10 2'"/>
<xsl:template name="main">
<xsl:for-each-group select="tokenize($s,'\s+')" group-by="(position()-1) idiv 2">
<xsl:sort select="number(current-group()[1])"/>
<xsl:sort select="number(current-group()[2])"/>
: <xsl:value-of select="current-group()"/>
</xsl:for-each-group>
</xsl:template>
</xsl:stylesheet>
$ saxon9 -it main sort.xsl
<?xml version="1.0" encoding="UTF-8"?>
: 1 0
: 1 1
: 1 2
: 1 3
: 1 4
: 2 0
: 2 1
: 2 3
: 2 4
: 5 0
: 6 0
: 10 0
: 10 1
: 10 2
David
________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.
This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Tokenized String Sorting , Abel Braaksma | Thread | RE: [xsl] Tokenized String Sorting , Houghton,Andrew |
| Re: [xsl] Tokenized String Sorting , Abel Braaksma | Date | RE: [xsl] Tokenized String Sorting , Houghton,Andrew |
| Month |