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

Re: query

Subject: Re: query
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sat, 8 Mar 2003 11:32:16 +0100
xpath template id
> I'm looking for an xpath query to get me the template node with the
largest
> version number from the largest subset of templates with the same id.
>
> The XML looks like:
>
> <Template id="1" version="0"/>
> <Template id="2" version="0"/>
> <Template id="3" version="0"/>
> <Template id="2" version="1"/>
>
> In the above XML, the answer to my query would be <Template id="2"
> version="1"/>

0. I added a top element to the source.xml above, to make it well-formed xml
document.

1. I understand this as a request to specify a *single* XPath expression
that returns the node with the specified properties.

2. I assume also, that the values of the "version" attributes of "Template"
elements having different id-s are independent from each other and are
increasing uniformly  from

    0
to
    count(/*/Template[@id = $thisId]) - 1

If these assumptions are correct, then the largest "version" for the largest
subset of "Template" elements with the same "id" -- this will be the maximum
for the values of the "version" attributes of the whole document above.


*In this case* the single XPath expression that returns the "Template"
element "with the largest version number from the largest subset of
templates with the same id" is:

   /*/*[not(@version < /*/*/@version)]

(One has to escape the "<" above in case this XPath expression has to be
specified as value of an attribute within an XML document)


In case the assumptions 1. and 2. do not hold, then there's no single XPath
1.0 expression that returns the wanted result -- the reason is that in XPath
1.0 it is not possible to have variable definitions as part of an
expression.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL







 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.