New to xsl / xml - reorder issue
Posted: Wed Jan 31, 2007 9:08 am
Hello all,
I am new to xml and xsl and am trying to reorder elements in an xml file to be output as an xml file that is being placed into Adobe InDesign.
My xml file to be reordered is written as such:
My xsl that I wrote looks like this:
What I get is this:
What I would like is this:
I would appreciate any advise.
I am new to xml and xsl and am trying to reorder elements in an xml file to be output as an xml file that is being placed into Adobe InDesign.
My xml file to be reordered is written as such:
Code: Select all
<advertisement>
<tester>
<three>Coloumn three</three>
<one>Column one</one>
<two>Column two</two>
</tester>
<tester>
<three>Second Coloumn three</three>
<one>Second Column one</one>
<two>Second Column two</two>
</tester>
<tester>
<three>Third Coloumn three</three>
<one>Third Column one</one>
<two>Third Column two</two>
</tester>
<tester>
<three>Fourth Coloumn three</three>
<one>Fourth Column one</one>
<two>Fourth Column two</two>
</tester>
<tester>
<three>Fifth Coloumn three</three>
<one>Fifth Column one</one>
<two>Fifth Column two</two>
</tester>
<tester>
<three>Sixth Coloumn three</three>
<one>Sixth Column one</one>
<two>Sixth Column two</two>
</tester>
</advertisement>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:element name="advertisement">
<xsl:element name="tester">
<!--Rearrange the order of the elements-->
<xsl:copy-of select="advertisement/tester/one"/>
<xsl:copy-of select="advertisement/tester/two"/>
<xsl:copy-of select="advertisement/tester/three"/>
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Code: Select all
<?xml version="1.0" encoding="UTF-16"?>
<advertisement>
<tester>
<one>Column one</one>
<one>Second Column one</one>
<one>Third Column one</one>
<one>Fourth Column one</one>
<one>Fifth Column one</one>
<one>Sixth Column one</one>
<two>Column two</two>
<two>Second Column two</two>
<two>Third Column two</two>
<two>Fourth Column two</two>
<two>Fifth two</two>
<two>Sixth Column two</two>
<three>Coloumn three</three>
<three>Second Coloumn three</three>
<three>Third Coloumn three</three>
<three>Fourth Coloumn three</three>
<three>Fifth three</three>
<three>Sixth Coloumn three</three>
</tester>
</advertisement>
Code: Select all
<advertisement>
<tester>
<one>Column one</one>
<two>Column two</two>
<three>Coloumn three</three>
</tester>
<tester>
<one>Second Column one</one>
<two>Second Column two</two>
<three>Second Coloumn three</three>
</tester>
<tester>
<one>Third Column one</one>
<two>Third Column two</two>
<three>Third Coloumn three</three>
</tester>
<tester>
<one>Fourth Column one</one>
<two>Fourth Column two</two>
<three>Fourth Coloumn three</three>
</tester>
<tester>
<one>Fifth Column one</one>
<two>Fifth Column two</two>
<three>Fifth Coloumn three</three>
</tester>
<tester>
<one>Sixth Column one</one>
<two>Sixth Column two</two>
<three>Sixth Coloumn three</three>
</tester>
</advertisement>
I would appreciate any advise.