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

XSLT Sort and choose last items problem

Subject: XSLT Sort and choose last items problem
From: "thei" <thei@xxxxxxxxx>
Date: Mon, 10 Feb 2003 00:04:29 +1000
xslt sort order
Hello.

I am trying to display the last 5 "days" from an XML file, sorted in
descending order.

Sample XML snippet:
<journal>
	<year>
		<month date="1">
			<day date="1">
				<contents/>
			<day date="2">
			...
		</month>
		<month date="2">
			<day date="1">
				<contents/>
			<day date="2">
			...
		</month>
		...
	</year>
</journal>

I currently use XSLT:
(Snippet:)
<xsl:for-each select="journal/year/month[last()]">
	<xsl:for-each select="day[position()>last()-5]">
		<xsl:sort order="descending" select="@date"/>
		<item>
			<xsl:call-template name="item-contents"/>
		</item>
	</xsl:for-each>
</xsl:for-each>

This does not quite do what I want to do. This is because I am unable to
select the last 5 days when they span "month" elements. For example,
when the last day in the XML file is 2 Feb, I want to select (in this
order) 2 Feb, 1 Feb, 31 Jan, 30 Jan, and 29 Jan. I can't figure out how
to select the days from January.

I hope I've explained that well enough.

Sincerely,

Ned Martin
http://nedmartin.org/




 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.