Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Removal of namespace in xslt - Urgent pls

Sen2008Dec 29 2010 — edited Feb 27 2020
All,
version: 11.1.1.3.
My incoming xml doc comes like this (sample one) into BPEL with namespace ns1
+*<?xml version="1.0" encoding="UTF-8" ?>*+
+*<ns1:OrderRequestHeader>*+
+*<ns1:ShipTo>*+
+*<ns1:Name xml:lang="en-US">P1- Atlanta</ns1:Name>*+
+*</ns1:ShipTo>*+
+*</ns1:OrderRequestHeader>*+

To remove such namespace I used the template as below
<?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" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="*">
<!-- remove element prefix (if any) -->
<xsl:element name="{local-name()}">
<!-- process attributes -->
<xsl:for-each select="@*">
<!-- remove attribute prefix (if any) -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

This template(googled it) remove all the namespace from element and also the attribute (*<ns1:Name xml:lang="en-US">P1- Atlanta</ns1:Name>*) i.e xml got removed from xml:lang. But I dont want to remove the namespace from attributes. Hence I removed the section below the commented line <!-- remove attribute prefix (if any) -->. This time the output just showed only the element without the attribute like this

<?xml version="1.0" encoding="UTF-8" ?>
<ns1:OrderRequestHeader>
<ns1:ShipTo>P1- Atlanta</ns1:Name>
</ns1:ShipTo>
</ns1:OrderRequestHeader>

But I want the output to be with attribute with xml namespace. How do I achieve that? I tried many combination in the template, but couldnt get thru. Any help is highly appreciated.

Thanks,
Sen
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 27 2011
Added on Dec 29 2010
2 comments
279 views