Here is the minimal code I want to add the namespace in the header tag. Here is my input XML.Can any one Help me.
<?xml version="1.0"?>
<R>
<M>
<H>1</H>
<B>
<p Ccy="GBP">1</p>
</B>
</M>
<M>
<H>1</H>
<B>
<p Ccy="GBP">4</p>
</B>
</M>
I have tried like this
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<xsl:output indent="yes" />
<xsl:template match="/*">
<R>
<M>
<xsl:apply-templates select="M[1]/H | M/B" />
</M>
</R>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
Expected output
<?xml version="1.0"?>
<R xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03 Y:\Data\Dokument\Kommunikation\Layouter\ISO20022\Sche\Pain001\Pain.001.001.03.xsd"
xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
<M>
<H>1</H>
<B>
<p Ccy="GBP">1</p>
</B>
<B>
<p Ccy="GBP">4</p>
</B>
</M>
Fiddle https://xsltfiddle.liberty-development.net/ej9EGbG/38
I have tried to add namespace in the header part.