cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT mapping to remove namespace prefix

ganguly05p
Explorer
0 Kudos

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

<?

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

Hi Pratyus

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

Rgds

Eng Swee

ganguly05p
Explorer
0 Kudos


Hi,

Thanks for the quick answer. I have already tried that. But it is not working in PI 7.3. Can you please help me with the xslt?

Thanks & regards,

Pratyus Ganguly

engswee
Active Contributor
0 Kudos

Hi Pratyus

XMLAnonymizerBean works fine when I try it with your payload. Here is the config, basically I included the namespace for everything except the ns0.

Parameter NameParameter Value
anonymizer.acceptNamespaceshttp://www.w3.org/2001/XMLSchema xsd http://www.w3.org/2001/XMLSchema-instance xsi http://schemas.xmlsoap.org/soap/envelope/ soap

Before

After

Rgds

Eng Swee

ganguly05p
Explorer
0 Kudos

Hi,

I have added the below module parameters in my soap receiver channel.

Parametr values i have given exactly same as you have mentioned

http://www.w3.org/2001/XMLSchema xsd http://www.w3.org/2001/XMLSchema-instance xsi http://schemas.xmlsoap.org/soap/envelope/ soap

But still ns0 prefixes are coming in the target message. Is there anything i am missing?

Thanks & regards,

Pratyus Ganguly

engswee
Active Contributor
0 Kudos

That's weird.

Since this is a SOAP receiver, how are you able to view that the content after the module still has the prefix? The content shown in the message monitor shows the value before any receiver module is executed. Are you able to login to the receiver system to view the payload there?

Anyway, try adding the following module, AF_Modules/MessageLoggerBean after the anonymizer, with the following parameters.

NameValue
log.locationremoveNS
log.condition1

With this you should be able to view the payload after anonymizer (as shown in my screenshot - under removeNS entry)

ganguly05p
Explorer
0 Kudos


i am checking in sxmb_moni.

engswee
Active Contributor
0 Kudos

SXMB_MONI is not the place to check since the module is executed in the receiver channel which is after the mapping step in the ABAP Integration Engine.

Please add the logger module as I described and check in the Adapter Engine Message Monitor.

ganguly05p
Explorer
0 Kudos

Not working.Still getting the same error. It would be great if you can help me with the xslt.

Thanks & Regards,

Pratyus Ganguly

Former Member
0 Kudos

I think you could use the XPI Inspector to see the payload in the adapter engine.

0 Kudos

Hi Pratyus,

XML Anonymizer should work, else you can try using the below XSLT mapping :

engswee
Active Contributor
0 Kudos

You might want to provide a screenshot of the error you are getting.

If you are unable to view the payload after the conversion, you cannot conclude that the error is because the Anonymizer bean not working.

I would suggest that you test out the web service manually first via SOAPUI to check that it works correctly before proceeding to make the changes in PI.

ganguly05p
Explorer
0 Kudos

Hi Eng,

Anonymizer bean is working. Target message is now getting generated without the namespace prefixes.

Thanks & Regards,

Pratyus Ganguly


engswee
Active Contributor
0 Kudos

Phew! Glad to know that it's finally working as it should be

Answers (1)

Answers (1)

Former Member
0 Kudos

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-x...