This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AW: Finding node having maximum value for an 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]