Is there a way to query an XML document to return the maximum of a given attribute using Xpath 1.0 ?
For example is there a way to get the max id ?
&
I've found that answers like the lwburk's or timbooo's work fine for attributes representing numbers having just one digit. However, if the attribute is a number having more than one digit, extrange things seem to happen when comparing between attributes' values. For example, try changing the original XML data with something like this:
Running the suggested snippets won't work. I got a solution using the casting operator xs:int() applied on id attribute, like in:
/library/book[not(xs:int(@id) <= preceding-sibling::book/@id) and not(xs:int(@id) <=following-sibling::book/@id)]
That will give the correct answer!