Skip to Content

XSLT mapping to remove namespace prefix

Hi experts,

I have one requrement where I need to remove the prefix ns0 from the xml (given below) getting generated in message mapping.

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns0:ExecuteRequest xmlns:ns0="http://test/">

<ns0:_sRequestXML><inteflow>body</inteflow></ns0:_sRequestXML></ns0:ExecuteRequest></soap:Body></soap:Envelope>

I am usimg the below xslt and it is now adding one ns0 prefix in the tag <inteflow>.

<?xml version="1.0" encoding="UTF-8"?>

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

<xsl:template match="/">

<ExecuteRequest xmlns="http://test/">

<_sRequestXML>

<inteflow>

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

</inteflow>

</_sRequestXML>

</ExecuteRequest>

</xsl:template>

</xsl:stylesheet>

Result after using xslt.

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ExecuteRequest xmlns="http://test/"><_sRequestXML>

<inteflow xmlns:ns0="http://decisionintellect.com/inteport/"></inteflow></_sRequestXML></ExecuteRequest></soap:Body></soap:Envelope>

Can you please help. What is wrong in the xslt and how I can get the desired result.

Thanks & Regards,

Pratyus Ganguly

<?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Apr 22, 2015 at 07:47 AM

    Hi Pratyus

    If you just want to remove prefix ns0 and the corresponding namespace, you can try using XMLAnonymizerBean

    Handling namespaces in PI using XMLAnonymizerBean - Important factors

    Rgds

    Eng Swee

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 22, 2015 at 05:40 PM

    I agree with Eng, XMLAnonymizer is best approach but if you want to try XSL here is an example:

    http://stackoverflow.com/questions/16810039/how-to-remove-namespace-prefix-leaving-namespace-value-xslt

    Add comment
    10|10000 characters needed characters exceeded