Saturday, 28 September 2013

recurse xml, howto select elements based on a condition of its children

recurse xml, howto select elements based on a condition of its children

I have an xml file with a structure as indicated below.
Question: How do I select/query those elements with children where the
sum(amount) from its children is unequal to its own amount?
There is no fixed amount of children and there are even elements with no
children, these later elements should not appear in the selection.
File structure arising from a json bubbletree file:
'<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="JSON">
<xs:complexType>
<xs:sequence>
<xs:element ref="label"/>
<xs:element ref="amount"/>
<xs:element ref="color"/>
<xs:element maxOccurs="unbounded" ref="children"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="label" type="xs:string"/>
<xs:element name="amount" type="xs:integer"/>
<xs:element name="color" type="xs:string"/>
<xs:element name="children">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="amount"/>
<xs:element ref="children"/>
<xs:element ref="color"/>
<xs:element ref="label"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>'
arising from a bubblechart json file.

No comments:

Post a Comment