0

HI guys,
i have split and xml in two parts, and in the root element element of the second one(which in this case is the output) want to add an attribute...but do not have any idea how to do this...
my XML:

<DataSet>
<Input>
<Order OrderNo="tesco10" DocumentTYpe="0001"/>
</Input>
<Output>
<Order OrderNo="Order1" CompanyCode="ABCD" OrderType="Sales">
<OrderLines>
<OrderLine PrimeLine="1"/>
</OrderLines>
</Order>
</Output>
</DataSet>

my xsl:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/DataSet/Output/Order">
<xsl:copy-of select="."/>
<xsl:apply-templates/>
</xsl:template>
</xsl:stylesheet>

the output:

<?xml version="1.0" encoding="UTF-16"?><Order OrderNo="Order1" CompanyCode="ABCD" OrderType="Sales">
<OrderLines>
<OrderLine PrimeLine="1" />
</OrderLines>
</Order>

desired output:

<?xml version="1.0" encoding="UTF-16"?>
<Order OrderNo="Order1" CompanyCode="ABCD" OrderType="Sales" Value="10USD">
<OrderLines>
<OrderLine PrimeLine="1" />
</OrderLines>
</Order>

thanks in advance....

2
Contributors
1
Reply
3
Views
5 Years
Discussion Span
Last Post by mrame
0

Please try with the below:

<xsl:template match="/DataSet/Output/Order">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:attribute name="test">test</xsl:attribute>
<xsl:copy-of select="*"/>
</xsl:copy>
<xsl:apply-templates/>
</xsl:template>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.