Skip to Content
0

Removing namespace prefix from xml file

Sep 19, 2017 at 09:59 AM

463

avatar image

Hi All,

Our scenarios is Proxy to mail.

SAP R/3 --> SAP GRC ---->SAP PI --> Business partners

We are sending xml file as a email attachment to business partners. It is convention in PI to use ns0 or nm as the prefix for the XML Schema namespace.

My client wants to remove the prefix "nm" when sending xml files to business partners.

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

<nm:nfeProc versao="3.10" xmlns:nm="http://www.portalfiscal.inf.br/nfe" xmlns="http://www.portalfiscal.inf.br/nfe">

-----

----

</nm:nfeProc>

--> We are using the SAP standard XSD.

--> I have tried using XML Anonymizer Bean in mail communication Channel to remove namespace prefix "nm" in XML Payload. please check the below configuration for your reference.

I also tried by placing the Anonymizer Bean before message transformebean but still no luck. please help us to resolve this issue.

Thanks in advance.

Regards

Bhargava Krishna

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Raghuraman S Sep 20, 2017 at 08:16 AM
0

Then you can try using UDF Krishna,We have similar req in CFDI where we need to change namespace prefix.

StructureNode node = ((StructureNode) container.getParameter("STRUCTURE_NODE"));
node.setNSDeclarations(" xmlns:" + prefix + "=" + namespace);
node.setQName(prefix + "test");
return"";

In prefix you can pass empty value and namespace as per requirement. And in the place for test you can select the message type

I tried to remove namespace prefix and seems working.


capture10.png (16.3 kB)
capture10.png (15.8 kB)
capture11.png (22.3 kB)
Share
10 |10000 characters needed characters left characters exceeded
Raghuraman S Sep 19, 2017 at 10:12 AM
0

Paramter name for quote is wrong I believe,Try anonymizer.quote

https://blogs.sap.com/2014/10/02/remove-namespace-by-xmlanonymizer-bean-in-communication-channel/

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Raghuraman,

Thanks for your response.

as specified in the link, i have configured the module key parameters in the communication channel, but still im prefix "nm" is not removed.

Parameter Name: anonymizer.quote

Parameter Value:

Regards

Bhargava Krishna

0
Mark Dihiansan Sep 20, 2017 at 03:05 AM
0

Hi Bhargava,

Since the values of the target namespace and unqualified namespace are the same, you can:

1. use a custom operation mapping (not the SAP provided one) to remove the namespace

2. use a custom adapter module to remove the namespace

Regards,

Mark

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Sep 19, 2017 at 10:19 AM
0

Hi Bhargava Krishna!

I don't understand why the same namespace is used both with prefix and without as default namespace.

Anyway, did you try to place XMLAnonymizerBean bean the first in the chain and set the namespace with empty prefix in module's parameters?

Like this: http://www.aaa.bbb/ccc '' (two single quotes).

And why do you set single quote as quotation mark? Do you have any issues with default mark?

Regards, Evgeniy.

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Eve I think requirement is to remove NS0 tags ,should be requirement in NFE or CFDI.
0

Hi Raghu,

No, our requirement is to remove prefix "nm" from the xml file received from SAP GRC system.

Yes this is Nfe interface.

Regards

Bhargava Krishna

0

Hi Raghu!

Thanks for clarification. I just wonder why the prefix is used in source message pointing to the same default namespace.

Regards, Evgeniy.

0

That should be target message Eve, the one which acts as web-service request.

1

Yes, Raghu, I got it. But question stays the same, even for target message. But nevermind! :-)

Regards, Evgeniy.

0

Yeah the declaration is strange ;)

1

Hi Eve,

Thanks for your prompt response.

This is SAP Nfe standard content,

Anyway, did you try to place XMLAnonymizerBean bean the first in the chain and set the namespace with empty prefix in module's parameters?

I have tried by configuring XMLAnonymizerBean in the first with empty prefix, issue still persist.

No i don't have any issues with the default mark, Quote parameter default value is ‘. i even tried by removing this optional parameter, but still no luck.

Regards

Bhargava Krishna

0
Peter Wallner Sep 20, 2017 at 02:11 PM
0

Hello Bhargava Krishna,

You can also use this XSL map to remove any namespaces:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0">
    
    <xsl:template match="*">
        <xsl:element name="{local-name()}">
            <xsl:apply-templates select="@* | node()"/>
        </xsl:element>
    </xsl:template>
    
</xsl:stylesheet>

You can use it as a first mapping step in your operation mapping.

Best regards, Peter

Share
10 |10000 characters needed characters left characters exceeded