Need to change target XML namespace
Source XML:
========
<FundXML>
<FundFacts>
<KeyFacts>
<Registration>
<Country>AE</Country>
</Registration>
<Registration>
<Country>AE</Country>
</Registration>
<Registration>
<Country>AT</Country>
</Registration>
<Registration>
<Country>AT</Country>
</Registration>
<Registration>
<Country>TW</Country>
</Registration>
<Registration>
<Country>ZA</Country>
</Registration>
</KeyFacts>
</FundFacts>
</FundXML>
Target XML:
========
<FundXML xsi:schemaLocation="www.fund1.com www.fund2.com"
xmlns="www.fund1.org/Schema" xmlns:xsi="http://www.fund2.org/Schema-Instance" >
<FundFacts>
<KeyFacts>
<Registration>
<Country>AE</Country>
</Registration>
<Registration>
<Country>AE</Country>
</Registration>
<Registration>
<Country>AT</Country>
</Registration>
<Registration>
<Country>AT</Country>
</Registration>
<Registration>
<Country>TW</Country>
</Registration>
<Registration>
<Country>ZA</Country>
</Registration>
</KeyFacts>
</FundFacts>
</FundXML>
Code
=======
Need to add
<FundXML xsi:schemaLocation="www.fund1.com www.fund2.com"
xmlns="www.fund1.org/Schema" xmlns:xsi="http://www.fund2.org/Schema-Instance" >
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:copy><xsl:apply-templates/></xsl:copy>
</xsl:template>
<xsl:template match="*[namespace-uri()='']">
<xsl:element name="{local-name()}" namespace="www.fund1.org/Schema">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Last edited by virgosaggi; April 28th, 2018 at 02:43 PM..
|