2

I have an xml structure like this.

    <pages>
        <page a="1">111</page>
        <page a="1" b="2">222</page>
        <page a="1">333</page>
        <page a="1" b="2" c="3" d="4">444</page>
        <page a="1" b="2">555</page>
        <page a="1">666</page>
    </pages>

Xpath should return the value 444 since that node has got the maximum number of attributes. How can we do this? Please help.

Jayy
  • 2,368
  • 4
  • 24
  • 35

2 Answers2

1

A similar question has already been asked and the conclusion is that it isn't really feasible yet. There doesn't seem to be a max() function in the current XPath specifications, so I think you'll have to apply some more complex code to get your answer... :)

Community
  • 1
  • 1
FarligOpptreden
  • 5,013
  • 22
  • 23
1

According to http://wiki.orbeon.com/forms/doc/developer-guide/xpath-2-0-support Orbeon supports XPath 2.0 so you can do stuff like /pages/page[count(@*) eq max(/pages/page/count(@*))].

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110