in one of my xml payload I need to add one namespace after the below line.
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate="">
after this I nedd to add the namespace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
the expected output should be
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate=""xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
could you please help on this. Let me elaborate my requirement. In the actual input message I am getting payload without any namespaces. It's look like below.
<?xml version="1.0" encoding="UTF-8"?>
<document>
</document>
in b/w the document we have rest of payload.
after that I have used XSLT code to add namespaces and prefixes in the payload. below is my XSLT code.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ep="namespace here"
xmlns:sh="namespace here"
xmlns:gk="namespace here">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Document">
<ep:Document>
<xsl:apply-templates select="node()|@*"/>
</ep:Document>
</xsl:template>
<xsl:template match="Extension|Extension//*">
<xsl:element name="gk:{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<xsl:template match="Header|Header//*">
<xsl:element name="sh:{name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:stylesheet>
after using this code the output I am getting looks like below.
<?xml version="1.0" encoding="UTF-8"?>
<ep:Document xmlns:ep="namespace here"
xmlns:gk="namespace here"
xmlns:sh="namespace here" schemaVersion="" creationDate="">
and rest of payload.so I need one more namespace after schema version and creationdate in the existing code as mentioned in the post.
ep:Document
element. Note that this is (another?) superfluous requirement: if your output needed a binding of thexsi
prefix, your processor would have automatically included it (or thrown an error). – michael.hor257k