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

Re: Node Selection

Subject: Re: Node Selection
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 15 Jun 2001 16:18:10 +0100
xsl node selection
Hi Jim,

> I am using Xalan for xsl transformations. I have some xml with
> multiple <Activity> nodes in it for each part that is processed. The
> activity nodes are not sorted in any way in the xml. I want to
> select only the latest activity (by Date, Time) to process in the
> transform for my output to show the last activity scan on this part
> and ignore all other activity scans.

The easiest way to do this is to sort the Activity elements by their
Date and Time (in descending order), and then choose the first one
only to go on and process:

<xsl:template match="Part">
   <xsl:for-each select="Activity">
      <xsl:sort select="Date" order="descending" />
      <xsl:sort select="Time" order="descending" />
      <xsl:if test="position() = 1">
         <xsl:apply-templates select="." />
      </xsl:if>
   </xsl:for-each>
</xsl:template>

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.