Subject: Sorting and grouping with xsl:analyze
From: "Philip Vallone" <philip.vallone@xxxxxxxxxxx>
Date: Thu, 26 Oct 2006 07:18:54 -0400
|
Hello,
I am having trouble grouping and sorting a string. From a previous post (RE:
Function to Extract integer from string), I extract some integers from
a string. Now I am trying to group & sort those integers. The following XSLT
outputs to html:
<xsl:for-each-group select="$XML1/manual/title/document(.)//Title"
group-by=".">
<xsl:if test="contains(., ''')">
<xsl:variable name="chap" select="."/>
<xsl:variable name="all" select="replace(.,'[^
0-9\.]','')"/>
<xsl:variable name="numbers" as="xs:string*">
<xsl:analyze-string select="."
regex="\d+\.?\d*">
<xsl:matching-substring>
<xsl:sequence select="."/>
</xsl:matching-substring>
</xsl:analyze-string>
</xsl:variable>
<xsl:for-each-group select="current-group()"
group-by="$numbers">
<xsl:sort/>
<xsl:for-each select="current-grouping-key()">
<xsl:value-of select="."/>
<p/>
</xsl:for-each>
</xsl:for-each-group>
</xsl:if>
</xsl:for-each-group>
The XML file looks like this:
<manual>
<title>MelChapter1.xml</title>
<title>Chapter9a.xml</title>
</manual>
The Results look like this:
21.197
21.197
21.199
91.407
1
121.133
91.12
121.135
I want to have it look like this:
1
21.197
21.199
91.12
91.407
121.133
121.135
Any help would be great.
Phil
|