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

sorting before selecting by position

Subject: sorting before selecting by position
From: "Russ Holmes" <russ1@xxxxxxxxxx>
Date: Mon, 20 Aug 2001 19:19:19 +1200
sort before paging xsl
Given XML;

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="C:\WebView\Root\WebView\Locations.xsl"?>
<xml>
	<rs>
		<z loc="NY" ldesc="New York Office" locno="1"/>
		<z loc="VAN" locdesc="Vancouver Office" locno="2"/>
		<z loc="LON" locdesc="London Office" locno="3"/>
		<z loc="DC" locdesc="Washington DC" locno="4"/>
		<z loc="QUE" locdesc="Quebec" locno="5"/>
		<z loc="CHI" locdesc="Chicago" locno="6"/>
		<z loc="KY" locdesc="Kentucky Office" locno="7"/>
		<z loc="LA" locdesc="Los Angeles County Office" locno="8"/>
		<z loc="TOR" locdesc="Toronto" locno="9"/>
		<z loc="MON" locdesc="Montreal" locno="10"/>
		<z loc="PAR" locdesc="Paris" locno="11"/>
		<z loc="SDY" locdesc="Sydney Office" locno="12"/>
		<z loc="MDR" locdesc="Marina del Rey" locno="13"/>
		<z loc="BUF" locdesc="Buffalo, NY" locno="14"/>
		<z loc="POR" locdesc="Portland Oregon Office" locno="15"/>
		<z loc="SF" locdesc="San Francisco" locno="16"/>
	</rs>
</xml>

I would like to sort according to attribute "loc" and then output rows with
position greater than 14 AFTER the sort ie

..
<z loc="TOR" locdesc="Toronto" locno="9" />
<z loc="VAN" locdesc="Vancouver Office" locno="2" />
..

I have tried XSL;

<?xml version="1.0"?>
<xsl:stylesheet version="1.0">

	<xsl:template match="*|/">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="text()|@*">
		<xsl:value-of select="."/>
	</xsl:template>

	<xsl:template match="/">
		<xsl:apply-templates select="//rs"/>
	</xsl:template>

	<xsl:template match="//rs">
		<rs>
			<xsl:apply-templates select="z[position() &gt; 14]">
			<xsl:sort select="@loc" data-type="text" order="ascending"/>
			</xsl:apply-templates>
		</rs>
	</xsl:template>

	<xsl:template match="//z">
		<z>
			<xsl:for-each select="@*">
				<xsl:copy>
					<xsl:apply-templates select="@* |  text()"/>
				</xsl:copy>
			</xsl:for-each>
		</z>

	</xsl:template>

</xsl:stylesheet>

but this results in;
...
<z loc="POR" locdesc="Portland Oregon Office" locno="15" />
<z loc="SF" locdesc="San Francisco" locno="16" />
..

as the position criteria is performed before the sorting..

How can I sort, then select according to a criteria?

This will eventually be part of a table based on Data islands using client
side paging and sorting.

Thanks for any help

Russ Holmes






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.