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

Re: AW: Finding node having maximum value for an attri

Subject: Re: AW: Finding node having maximum value for an attribute
From: Antonio Fiol Bonnín <fiol@xxxxxxxxxx>
Date: Fri, 31 May 2002 11:57:46 +0200
xpath select highest id attribute
Or, as was suggested to me on this list, you can use

<xsl::value-of select="//Archive[not(../Archive/@ID > @ID)]/@ID" />

Which I found a very compact and nice way of understanding the problem.


Explanation: Look for the ID attribute of an Archive node for which it does NOT exist any ../Archive (sibling Archive) node whose ID is greater than its (the first node I referenced) ID.


Did you understand my English? I do not...

I'll rephrase:

We look for the ID of the Archive node with the greatest ID. That is, we look for (the ID of) a node whose ID is greater or equal than any other. That is, we look for (the ID of) a node whose ID is NOT strictly lower than ANY of his siblings.

That's better for my English skills, I believe ;-)


Antonio Fiol



Pfitzner, Jan wrote:


Yes, you can.
You can sort the Archive-nodes using the ID with xsl:sort and extract the first or last node of the sorted tree.
<xsl:variable name="max">
	<xsl:sort data-type="number" select="//Archive/@ID" order="descending"/>
	<xsl:value-of select="//Archive[1]/@ID"/>
</xsl:variable>

JP

<Archives>
<Archive ID="1">
<somenode>somevalue</somenode>
<someothernode>someothervalue</someothernode>
</Archive>
<Archive ID="2">
<somenode>somevalue</somenode>
<someothernode>someothervalue</someothernode>
</Archive>
</Archives>

Now my question is, is it possible to wite a XPath query which will return
me the highest ID attribute if Archive node in the whole file???



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

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.