S
Steve Mac
I am very new to XML / XSL and am having trouble with transforming a
flat xml file into a hierarchical format using an id / parentid
attribute relationship. Any help on this would be greatly appreciated.
I have an XML document in the following format (there are other
extraneous attributes I've removed for simplicity):
<?xml version="1.0" encoding="UTF-8"?>
<sitenav>
<navitem id="10423" displaytitle="A Child" parentid="" />
<navitem id="10421" displaytitle="A Grandchild" parentid="10423" />
<navitem id="10476" displaytitle="A Great Great Grandchild - parent
is 10434" parentid="10434" />
<navitem id="10424" displaytitle="Another Grandchild"
parentid="10423" />
<navitem id="10434" displaytitle="A Great Grandchild - parent is
10421" parentid="10421" />
<navitem id="10425" displaytitle="Another child" parentid="" />
...
</sitenav>
And need to transform it into this format:
<?xml version="1.0" encoding="UTF-8"?>
<sitenav>
<navitem id="10423" displaytitle="A Child" parentid="">
<navitem id="10421" displaytitle="A Grandchild" parentid="10423">
<navitem id="10434" displaytitle="A Great Grandchild - parent is
10421" parentid="10421">
<navitem id="10476" displaytitle="A Great Great Grandchild - parent
is 10434" parentid="10434" />
</navitem>
</navitem>
<navitem id="10424" displaytitle="Another Grandchild" parentid="10423"
/>
</navitem>
<navitem id="10425" displaytitle="Another child" parentid="" />
...
</sitenav>
Thanks,
Steve
flat xml file into a hierarchical format using an id / parentid
attribute relationship. Any help on this would be greatly appreciated.
I have an XML document in the following format (there are other
extraneous attributes I've removed for simplicity):
<?xml version="1.0" encoding="UTF-8"?>
<sitenav>
<navitem id="10423" displaytitle="A Child" parentid="" />
<navitem id="10421" displaytitle="A Grandchild" parentid="10423" />
<navitem id="10476" displaytitle="A Great Great Grandchild - parent
is 10434" parentid="10434" />
<navitem id="10424" displaytitle="Another Grandchild"
parentid="10423" />
<navitem id="10434" displaytitle="A Great Grandchild - parent is
10421" parentid="10421" />
<navitem id="10425" displaytitle="Another child" parentid="" />
...
</sitenav>
And need to transform it into this format:
<?xml version="1.0" encoding="UTF-8"?>
<sitenav>
<navitem id="10423" displaytitle="A Child" parentid="">
<navitem id="10421" displaytitle="A Grandchild" parentid="10423">
<navitem id="10434" displaytitle="A Great Grandchild - parent is
10421" parentid="10421">
<navitem id="10476" displaytitle="A Great Great Grandchild - parent
is 10434" parentid="10434" />
</navitem>
</navitem>
<navitem id="10424" displaytitle="Another Grandchild" parentid="10423"
/>
</navitem>
<navitem id="10425" displaytitle="Another child" parentid="" />
...
</sitenav>
Thanks,
Steve