cancel
Showing results for 
Search instead for 
Did you mean: 

My mapping expecting <ns0 for every element

NishantChavan
Participant
0 Kudos

Hi Experts,

I have an inbound interface, the XSD is shared by the partner and its used in the mapping. The mapping is expecting <ns0 in the beginning of every element however the XML we are getting from partner does not have it. How do I add it or what i can do to process the XML's

XML expected by PI mapping

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

<ns0:ED xmlns:ns0="http://www.abc.com/ED">

   <ns0:Header>

      <ns0:Period/>

      <ns0:Count/>

   </ns0:Header>

   <ns0:ED1>

      <ns0:SAP/>

      <ns0:WorkDate/>

   </ns0:ED1>

</ns0:ED>

XML sent by partner

<ear:ED xmlns:ear="http://www.abc.com/ED">

  <Header>

    <Period>4</Period>

    <Count>4</Count>

  </Header>

  <ED1>

    <SAP>00813518</SAP>

    <WorkDate>121212</WorkDate>

  </ED1>

   

Thanks,

Nishant Chavan

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Nishant,

You can use XSLT also you can create a UDF with the following code to set the required NS qualifier to each

     StructureNode node = ((StructureNode) container.getParameter("STRUCTURE_NODE"));

     node.setNSDeclarations(" xmlns:ns0=\"http://sap.com/xi/XXXX\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:yourNS=\"http://abc.com/" xsi:schemaLocation=\"http://abc.com " "); // notice the space before xmlns:

node.setQName("ns0:yourelement");

return "";

juan_vasquez2
Active Participant
0 Kudos

Hi Nishant,

Modify your xsd File, use elementFormDefault="qualified", then the mapping use not ns0

then import again

something like this in the schema  of your XSD

  <types>

    <xsd:schema targetNamespace="http://xmlns.cocose.com/ora/INTC/WEB_POPO_WS/TAKE" elementFormDefault="qualified">

      <xsd:element name="CXMLTYPE-TAKEN">

Regards Juan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Nishant,

                    Ask the sender to send proper XSD or change the supplied XSD in editor to something like this

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

<ear::ED xmlns:ns0="http://www.abc.com/ED">

   <Header>

      <Period/>

      <Count/>

   </Header>

   <ED1>

      <SAP/>

      <WorkDate/>

   </ED1>

</ear:ED>

Regards

Anupam

turmoll
Active Contributor
0 Kudos

Wouldn't it make sense to enquire partner why they are sending wrong XML? The XML they send is not valid against the schema! Change the XSD or XML. Make things in order. Don't make workaround.

/k

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Nishant,

Are you using just one xsd? Adding or changing elementFormDefault="qualified" could do the trick.

Regards.

Mark

former_member190293
Active Contributor
0 Kudos

Hi Nishant!

You can use XSL transformation:

<?xml version='1.0'?>

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

                                           xmlns:ns0="http://www.abc.com/ED"

                                           xmlns:ear="http://www.abc.com/ED"

                                           exclude-result-prefixes="ear">

     <xsl:output omit-xml-declaration="yes" indent="yes"/>

    

     <xsl:template match="*">

          <xsl:element name="ns0:{local-name()}">

               <xsl:apply-templates select="node()|@*"/>

          </xsl:element>

     </xsl:template>

</xsl:stylesheet>

Regards, Evgeniy.

Harish
Active Contributor
0 Kudos

Hi Nishant,

you can use the XSLT code given in the below thread

regards,

Harish