Selecting highest count
I have the following XML:
<curve>
<data>
<x>1</x>
<y>5</y>
</data>
</curve>
<curve>
<data>
<x>1</x>
<y>5</y>
</data>
</curve>
<curve>
<data>
<x>1</x>
<y>5</y>
</data>
<data>
<x>1</x>
<y>5</y>
</data>
</curve>
Note that the first two <curve>s contain one <data>, and the last <curve> contains two <data> elements.
I am trying to write an XPath expression that would return the highest <curve>/<data> count. In this instance, it would return 2. If another <curve> existed that contained 6 <data> elements, the expression would return 6.
I can come up with some bloated XSLT code using <xsl:for-each> to finally get to the number, but I know there must be a simpler way using XPath 2.0.
BTW, I am using Saxon8.
Any help is greatly appreciated.
|