I have an xml that has an element which is recursive. A category node has it’s own definition and also the ancestors of that category. Those ancestors repeat this structure till the top most category. To make things complicated, a product can have multiple category paths. In order to identify the top-most category, I used
This worked fine in Java. But when I tried the same in Perl (XML::XPath), it didn’t work. It turned out, the inner most Category happened to be the first one within the descendant::Category nodeset. So, using
it worked. But I wanted an xpath expression that is language independent.
So, I ended up using
I am not sure if the perl implementation of the xpath is incorrect or if the xpath specification is unclear on the ordering of the nodes for certain type of expressions.