cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Namespace from XML File except Attribute

Former Member
0 Kudos

Hi XI Experts ,

1.I have referred to the code of xslt Generic XSLT Code to Remove ALL Namespaces from XML:

http://forums.sdn.sap.com/thread.jspa?threadID=1920630

But this removes the Attribute : id from the records .

My expected output is supposed to be :

<?xml version="1.0" encoding="GBK"?>

<body>

<head>

<nsrsbh>112001069711</nsrsbh>

<nsrmc>诺维信(中国)生物技术有限公司出口发票</nsrmc>

<dcrq>20120209</dcrq>

<sssq_q>20111201</sssq_q>

<sssq_z>20120207</sssq_z>

<records>4</records>

</head>

<data>

<record id="1">

<fpdm></fpdm>

</record>

</data>

</body

But after using this XSLT code it removes :id from <record_1 id=> and generated the below code :

The xml file now doesn't contain teh attribute :id

<?xml version="1.0" encoding="GBK"?>

<body>

<head>

<nsrsbh>112001069711</nsrsbh>

<nsrmc>诺维信(中国)生物技术有限公司出口发票</nsrmc>

<dcrq>20120209</dcrq>

<sssq_q>20111201</sssq_q>

<sssq_z>20120207</sssq_z>

<records>4</records>

</head>

<data>

<record>

1

<fpdm></fpdm>

</record>

</data>

</body>

Could you please provide your input

Plaese note : Here XI versin iS x1 3.0 SP7 . I have tried suing the Analyzer bean for the Encoing of Chinese : GBK Intsead of UTF-8 in the Namespace . But AF_Modules/XMLAnonymizerBean is not comptacible with XI 3.0 SP7

Hence i have used the following code to remove namespcae and add Encoding :GBK instead of UTF-8:

<?xml version="1.0" ?>

<xsl:stylesheet

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

<xsl:output encoding="GBK"/>

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

<xsl:copy>

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

</xsl:copy>

</xsl:template>

</xsl:stylesheet>

Accepted Solutions (0)

Answers (1)

Answers (1)

iaki_vila
Active Contributor
0 Kudos

You could use exclude-result-prefixes.

For example:


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wt="http://www.example.com" exclude-result-prefixes="wt"> 

...

</xsl:stylesheet>