Skip to Content
avatar image
Former Member

Payload namespace clarification

Hi,

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

<ns0:MT_SAMPLE xmlns:ns0="urn:ns_lisa_impl_rad">

<NAME/>

</ns0:MT_SAMPLE>

This my default Payload.

can anyone explain me what is "ns0" mean in this payload?

can we change it?

Thanks,

RPN

Edited by: RPN on Sep 1, 2008 3:37 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Sep 02, 2008 at 06:53 AM

    Hi,

    Check with this

    How to remove namespaces in Mapping - XI

    Regards

    Seshagiri

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 01:46 PM

    The namespace prefic ns0 is only a placeholder for the namespace

    when you have multiple namespaces defined in your XSD, you'll get these ns0, ns1 to identify which fields are from which name space.

    more details refer:

    What's the rule of ns0, ns1, ns2, ...

    to change it refer

    remove-ns0-from-source-message

    ns0-in-all-the-element-tag-of-the-xml-output-file

    namespace-ns0-generated-in-each-node-and-field

    Edited by: preethi Prabhu RadhaKrishnan on Sep 1, 2008 4:02 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi,

      i tried removing the namespace prefix but i couldn't....

      i followed this blog:

      https://blogs.sap.com/?p=43421

      how remove the prefix...

      Actual payload:

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

      <ns0:MT_SAMPLE xmlns:ns0="urn:ns_lisa_impl_rad">

      <NAME/>

      </ns0:MT_SAMPLE>

      Desired payload:

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

      <MT_SAMPLE xmlns="urn:ns_lisa_impl_rad">

      <NAME/>

      </MT_SAMPLE>

      suggestions please....

      Thanks,

      RPN

  • Sep 02, 2008 at 07:10 AM

    Hi,

    Basically i think it is possible with XMLAnonymizerBean module in adapter module parameter tab:

    You use this module to anonymize XML elements and attributes by removing namespaces or namespace prefixes from the XML document of the main payload.

    You can define a particular namespace prefix for each namespace. You can also change the encoding attribute of the XML declaration.

    Refer the weblog as well as help:

    https://blogs.sap.com/?p=43421

    http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm

    Regards,

    Vinod.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      hi vinod,

      i followed the link which u have mentioned...

      i could change the prefix.... but i couldn't remove the prefix...

      (Note: without removing the namespace)

      help me on this...

      Thanks,

      RPN

      Edited by: RPN on Sep 2, 2008 10:13 AM

  • avatar image
    Former Member
    Sep 02, 2008 at 08:40 AM

    Hi,

    One of the biggest misunderstandings in XML is namespaces. There's absolutely no difference to an xml parser or to the interpretation of a document whether you use a prefix on every node, or a default namespace. Prefixes are only a syntactic abbreviation. In other words:

    <mydoc xmlns="uri:my-namespace">

    <subnode />

    </mydoc>

    (Default namespace flows into the child - there is no prefix, so it uses the default namespace)

    is identical to:

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <ns0:subnode xmlns:ns1="uri:my-namespace" />

    </ns0:mydoc>

    (The prefix ns0 maps to uri:my-namespace, and both nodes are marked with ns0)

    and to:

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <ns1:subnode xmlns:ns1="uri:my-namespace" />

    </ns0:mydoc>

    (No default namespace, but ns0 and ns1 both map to uri:my-namespace and hence have identical meaning)

    and

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <subnode xmlns="uri:my-namespace" />

    </ns0:mydoc>

    (ns0 is defined on the parent, but we then set a default namespace for this node - and any children, if it had any)

    In all of the cases above, the namespace of subNode is uri:my-namespace.

    It turned out in the end that the problem was that the schema defined the namespace as "uri:my-namespace" but the result document was coming back with a namespace of "uri:my-namespace/" - the trailing slash being all important. Remember folks, namespaces are just strings - a trailing slash may not make a difference to most Internet browsers, but they do in XML Schema.

    ElementFormDefault

    As a bonus, a little note on elementFormDefault.

    If in your schema you use elementFormDefault="qualified" then you can validate all of the documents above with a schema similar to (pseudo-code):

    <xs:schema targetNamespace="uri:my-namespace" elementFormDefault="qualified">

    <xs:element name="myDoc">

    <xs:complexType>

    <xs:sequence>

    <xs:element name="subnode" maxOccurs="1" />

    </xs:sequence>

    </xs:complexType>

    </xs:element>

    </xs:schema>

    If you changed the elementFormDefault to "unqualified" then instead it would only look for the root element to be in the namespace, and child elements would be unqualified (in the empty namespace):

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <subnode/>

    </ns0:mydoc>

    and

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <ns1:subnode xmlns:ns1=""/>

    </ns0:mydoc>

    (An explicitly empty prefixed namespace definition)

    and

    <ns0:mydoc xmlns:ns0="uri:my-namespace">

    <subnode xmlns=""/>

    </ns0:mydoc>

    (An explicitly empty default namespace definition for the sub node, and its child nodes if it had any)

    Add comment
    10|10000 characters needed characters exceeded