This is my XML
using XSLT
:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestResponse xmlns="http://tempuri.org/">
<RequestResult>
<Message>Request inserted successfully.</Message>
<Response>true</Response>
</RequestResult>
</RequestResponse>
</s:Body>
</s:Envelope>
And I want to add two namespaces in the RequestResult
node (The result I want):
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<RequestResponse xmlns="http://tempuri.org/">
<RequestResult xmlns:a="http://schemas.datacontract.org/2004/07/MockupTesting" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Message>Request inserted successfully.</a:Message>
<a:Response>true</a:Response>
</RequestResult>
</RequestResponse>
</s:Body>
</s:Envelope>
I use this XSLT:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<xsl:output omit-xml-declaration="yes" indent="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*" />
</xsl:copy>
</xsl:template>
<xsl:template match="/">
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<xsl:apply-templates />
</s:Body>
</s:Envelope>
</xsl:template>
<xsl:template match="RequestResult |RequestResult //*">
<xsl:element name="a:{name()}"
namespace="http://schemas.datacontract.org/2004/07/MockupTesting">
<xsl:copy-of select="namespace::*" />
<xsl:apply-templates select="node()|@*" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
But I need to add to the SolicitarPeticionResult
node (which already contains a namespace):
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"