flat xml file to hierarchical using xsl

admin

Administrator
Staff member
I currently have something like the following xml file;

<document>
<textheading level="1">heading text</textheading>
<textheading level="2">heading text</textheading>
<textparagraph>text</textparagraph>
<textheading level="3">heading text</textheading>
<textparagraph>text</textparagraph>
<textheading level="3">heading text</textheading>
<textparagraph>text</textparagraph>
<textheading level="2">heading text</textheading>
<textparagraph>text</textparagraph>
<textheading level="3">heading text</textheading>
<textparagraph>text</textparagraph>
</document>

I want to nest these and create the following using an xsl file;

<document>
</documenttitle>heading text</documenttitle>
<textheading1>
<heading>heading text</heading>
<textheading2>
<heading>heading text</heading>
<textparagraph>text</textparagraph>
<textheading3>
<heading>heading text</heading>
<textparagraph>text</textparagraph>
<textparagraph>text</textparagraph>
</textheading3>
<textheading3>
<heading>heading text</heading>
<textparagraph>text</textparagraph>
<textparagraph>text</textparagraph>
</textheading3>
</textheading2>
<textheading2>
<heading>heading text</heading>
<textparagraph>text</textparagraph>
<textheading3>
<heading>heading text</heading>
<textparagraph>text</textparagraph>
<textparagraph>text</textparagraph>
</textheading3>
</textheading2>
</textheading1>
</document>

Is there anyone out there who can point me to an existing xslt stylesheet that does this?

Just to give a little more background, I am using the openoffice.org writer word processor and want to convert the content xml file(the first above xml file format) into another xml file format (the second of the above formats).

thanks in advance for any help
 
Back
Top