Hello,
i convert one XML-document by using XSLT into another XML-document. First change all attributes to elements is no problem. Then i try to insert a new element into the new document by XSLT, but it doesn't work correctly :-(
Example:
The XML-source-document:
<?xml version="1.0" encoding="UTF-8"?>
<data creationTime="2006-05-31" creationNumber="1">
<set number="0001" info="test"/>
<set number="0002" info="test"/>
</data>
The following XML-destination-document has to become
(watch the new element "sets"):
<?xml version="1.0" encoding="UTF-8"?>
<data>
<creationTime>2006-05-31</creationTime>
<creationNumber>1</creationNumber>
<sets>
<set>
<number>0001</number>
<info>test</info>
</set>
<set>
<number>0002</number>
<info>test</info>
</set>
</sets>
</data>
Here is my XSLT-stylesheet-attempt:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl
utput method="xml" indent="yes" /> <xsl:template match="@*"> <xsl:element name="{name}"> <xsl:value-of select="."/> </xsl:element> <xsl:if test="name='creationNumber'"> <sets/> </xsl:if> </xsl:template> <xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="*|@*"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
Here is the result with wrong positioned "sets":
<?xml version="1.0" encoding="UTF-8"?>
<data>
<creationTime>2006-05-31</creationTime>
<creationNumber>1</creationNumber>
<sets/>
<set>
<number>0001</number>
<info>test</info>
</set>
<set>
<number>0002</number>
<info>test</info>
</set>
</data>
The element "sets" should not to be positioned simply before the first set-Element, it should be positiond around the set-Elements, thus as shown in the XML Destinationdocument above.
Can anybody give me an XSLT-hint?
Thanks
i convert one XML-document by using XSLT into another XML-document. First change all attributes to elements is no problem. Then i try to insert a new element into the new document by XSLT, but it doesn't work correctly :-(
Example:
The XML-source-document:
<?xml version="1.0" encoding="UTF-8"?>
<data creationTime="2006-05-31" creationNumber="1">
<set number="0001" info="test"/>
<set number="0002" info="test"/>
</data>
The following XML-destination-document has to become
(watch the new element "sets"):
<?xml version="1.0" encoding="UTF-8"?>
<data>
<creationTime>2006-05-31</creationTime>
<creationNumber>1</creationNumber>
<sets>
<set>
<number>0001</number>
<info>test</info>
</set>
<set>
<number>0002</number>
<info>test</info>
</set>
</sets>
</data>
Here is my XSLT-stylesheet-attempt:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl
Here is the result with wrong positioned "sets":
<?xml version="1.0" encoding="UTF-8"?>
<data>
<creationTime>2006-05-31</creationTime>
<creationNumber>1</creationNumber>
<sets/>
<set>
<number>0001</number>
<info>test</info>
</set>
<set>
<number>0002</number>
<info>test</info>
</set>
</data>
The element "sets" should not to be positioned simply before the first set-Element, it should be positiond around the set-Elements, thus as shown in the XML Destinationdocument above.
Can anybody give me an XSLT-hint?
Thanks