Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9021

Re: Avoid repeating namespace declaration in xml output

$
0
0

Hi Mon,

 

 

You can use below xslt 1.0 mappings.

The first one will copy all namespaces (declared) to a newly created root element.

The seconde one will delete the 'old' root element.

 

=> The result will look like an xml where the namespacesare moved to the root element.

 

First xslt:

 

<?xml version='1.0' encoding='utf-8'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="/">

<Invoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:ns3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:ns4="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2">

<xsl:copy-of select="." />

</Invoice>

</xsl:template>

</xsl:stylesheet>

 

Second xslt:

 

<?xml version='1.0' encoding='utf-8'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" encoding="UTF-8"/>

<xsl:template match="@* | node()">

  <xsl:copy>

    <xsl:apply-templates select="@* | node()"/>

  </xsl:copy>

</xsl:template>

<xsl:template match="Invoice" >

  <xsl:apply-templates/>

</xsl:template>

</xsl:stylesheet>

 

Kind regards,

 

Lode


Viewing all articles
Browse latest Browse all 9021

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>