Add attribute to node
Posted: Mon May 13, 2019 11:52 am
HI!
I am trying to transform a XML file using a XSLT. I made all the transformations required but I am not able to modify attributes in SOAP-ENV:ENVELOPE node.
I need to add some attributes to SOAP-ENV:Envelope node and to give the some value.
This is my XML:
This is my XSLT (myxsltfile):
And this is the expected output:
<?xml version="1.0"?>
<?xml-stylesheet href="myxsltfile.xsl" type="text/xsl"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xmm= "http://namespace.com/xml/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
/>
<SOAP-ENV:Body>
<...GENERAL TAGS.../>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Any help is welcome! Thanks!
I am trying to transform a XML file using a XSLT. I made all the transformations required but I am not able to modify attributes in SOAP-ENV:ENVELOPE node.
I need to add some attributes to SOAP-ENV:Envelope node and to give the some value.
This is my XML:
Code: Select all
<?xml version="1.0"?><?xml-stylesheet href="myxsltfile.xsl" type="text/xsl"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
<...GENERAL TAGS.../>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Code: Select all
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:template match="SOAP-ENV:Envelope">
<xsl:copy>
<xsl:attribute name="xmlns:xmm">
<xsl:value-of select= "'http://namespace.com/xml/"/>
</xsl:attribute>
<xsl:attribute name="xmlns:xsd">
<xsl:value-of select= "'http://www.w3.org/2001/XMLSchema'"/>
</xsl:attribute>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0"?>
<?xml-stylesheet href="myxsltfile.xsl" type="text/xsl"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xmm= "http://namespace.com/xml/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
/>
<SOAP-ENV:Body>
<...GENERAL TAGS.../>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Any help is welcome! Thanks!