[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Flattening hierarchic xml, retaining some structure


Subject: [xsl] Flattening hierarchic xml, retaining some structure
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Wed, 19 Jan 2005 14:56:08 +0000

Hi, I have a hierarchic structure, that I would like to flatten.
I have tried looking for some examples, but I have not been able to expand the examples I have found, so that they will work on my problem.
(I have no influence on either input or output format, which is simplified here)


Regards,
Ragulf Pickaxe :-)

Expanding on the example from David Pawson's site:
http://www.dpawson.co.uk/xsl/sect2/flatten.html
I have the following XML and would like to generate the flat structure as shown:


Input XML:
<mynode name="xxx">
 <subnode>Some text</subnode>
 <subnode>
   <mynode name="yyy">
     <subnode><b>Some bold text</b></subnode>
     <subnode>Some text where some of it is <b>bold text</b></subnode>
     <subnode>
       <mynode name="zzz">
         <subnode>Some text</subnode>
         <subnode>Some text</subnode>
       </mynode>
     </subnode>
     <subnode>Yet some text</subnode>
   </mynode>
 </subnode>
 <subnode>Some more text, <i>italic</i> is some of it</subnode>
</mynode>

Output XML:
<mynode name="xxx">
 <subnode>Some text</subnode>
<mynode name="yyy">
 <subnode><b>Some bold text</b></subnode>
 <subnode>Some text where some of it is <b>bold text</b></subnode>
</mynode>
<mynode name="zzz">
 <subnode>Some text</subnode>
 <subnode>Some text</subnode>
</mynode>
<mynode name="yyy">
 <subnode>Yet some text</subnode>
</mynode>
<mynode name="xxx">
 <subnode>Some more text, <i>italic</i> is some of it</subnode>
</mynode>

I have tried some various forms of modes, and such, but alas no success, and no idea how to obtain success. The problem is with retaining the subnode under mynode structure, while also having the subnodes in the same document order as in the input.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/



Current Thread
Keywords
xml