[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Sorting and grouping with xsl:analyze

Subject: Sorting and grouping with xsl:analyze
From: "Philip Vallone" <philip.vallone@xxxxxxxxxxx>
Date: Thu, 26 Oct 2006 07:18:54 -0400
 Sorting and grouping with xsl:analyze
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.