I have the following XML document as an input (InputXML) to a Java program that applies a XSL (TransformationXSL) to convert to output XML (OutputXML).
I want to add an extra node as part of the transformation of the input XML. Is there a better way than what is being shown in the (TranformationXSL), as this just tries to match the element and copy what's required??? Any other efficient way / suggestion is much appreciated.
InputXML
<?xml version="1.0" encoding="UTF-8"?>
<tuple>
<old>
<Customers>
<OrderID>10248</OrderID>
<CustomerID>VINET</CustomerID>
<EmployeeID>8</EmployeeID>
<OrderDate>1996-07-04T00:00:00.0</OrderDate>
<CustomerID>VINET</CustomerID>
<CompanyName>Vins et alcools Chevalier</CompanyName>
</Customers>
</old>
</tuple>
OutputXML
<?xml version="1.0" encoding="UTF-8"?>
<tuple>
<old>
<Customers>
<Orders>
<OrderID>10248</OrderID>
<CustomerID>VINET</CustomerID>
<EmployeeID>8</EmployeeID>
<OrderDate>1996-07-04T00:00:00.0</OrderDate>
</Orders>
<CustomerID>VINET</CustomerID>
<CompanyName>Vins et alcools Chevalier</CompanyName>
</Customers>
</old>
</tuple>
This is the TransformationXSL that I was talking about. Can this be modified to efficiently transform the input XML to give the desired output XML???
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" indent="yes" />
<xsl:strip-space elements="*" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="Customers">
<Customers>
<Orders>
<OrderID>10248</OrderID>
<CustomerID>VINET</CustomerID>
<EmployeeID>8</EmployeeID>
<OrderDate>1996-07-04T00:00:00.0</OrderDate>
</Orders>
<CustomerID>VINET</CustomerID>
<CompanyName>Vins et alcools Chevalier</CompanyName>
</Customers>
</xsl:template>
</xsl:stylesheet>
Ordersand few not?