Transformation d'un XML avec une hiérarchie imbriquée en XML simple
Bonjour,
J'ai un XML avec une structure hiérarchique imbriquée (tag type)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?xml version="1.0" encoding="UTF-8"?>
<ns1:racine xmlns:ns1="http://test.yo">
<type ref="01">
<attrib ref="A01">
</attrib>
<attrib ref="A02">
</attrib>
<type ref="02">
<attrib ref="A03">
</attrib>
<attrib ref="A04">
</attrib>
<type ref="03">
<attrib ref="A05">
</attrib>
<attrib ref="A06">
</attrib>
</type>
</type>
</type>
</ns1:racine> |
J'aimerais remplacer cette hiérarchie par un XML qui fait référence au tag ancêtre (attribut refsup du tag <type> qui fait ainsi référence au tag supérieur)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
<?xml version="1.0" encoding="UTF-8"?>
<ns1:racine xmlns:ns1="http://test.yo">
<type ref="01">
<attrib ref="A01">
</attrib>
<attrib ref="A02">
</attrib>
</type>
<type ref="02" refsup="01">
<attrib ref="A03">
</attrib>
<attrib ref="A04">
</attrib>
</type>
<type ref="03" refsup="02">
<attrib ref="A05">
</attrib>
<attrib ref="A06">
</attrib>
</type>
</ns1:racine> |
J'avais pensé à éventuellement une XSLT avec un traitement récursif mais je ne vois pas trop comment implémenter cela car je suis assez débutant en XSLT.
Est-ce que quelqu'un pourrait m'aider ?
Merci d'avance de votre collaboration.
E. Koralewski