xsl-list
[Top] [All Lists]

[xsl] Sorting and grouping with xsl:analyze

2006-10-26 04:19:20
Hello,

I am having trouble grouping and sorting a string. From a previous post (RE:
[xsl] 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





--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>