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

Filter by id and date

Subject: Filter by id and date
From: Emma Burrows <Emma.Burrows@xxxxxxxxxxx>
Date: Mon, 5 Sep 2011 10:36:00 +0100
 Filter by id and date
Hopefully a quick question. Using XSLT 2.0, I am filtering entries in an input
file based on their ids. The only problem is that I've been given an update to
the original input file which includes many duplicates, some of which are
identical and some of which have been updated. For any given id, I need to
look up the item with the most recent date.

So say I have the following input file:

<items>
  <item id='1' date='2011'>Item1</item>
  <item id='2' date='2009'>Item2</item>
  <item id='3' date='2002'>Item3</item>
  <item id='2' date='2011'>Item2</item>
  <item id='3' date='2002'>Item3</item>
</items>

For example, the Xpath in question looks like this right now (long-winded but
more efficient path-finding syntax simplified to // for this example, and
$idref obviously contains a valid id):

<xsl:value-of select="normalize-space(//item[@id=$idref])"/>

What is the best way to filter that to return only the item whose @date is the
highest for all items with @id=$idref?

Thanks!

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.