Skip to Content
author's profile photo Former Member
Former Member

how to add mulitple namespace in xml

Hi,

I have this output xml:

<?xml version="1.0" encoding="utf-8" ?> 
- <E24B:E24B_Update_MachineCards_001 xmlns:E24B="urn:E24B_UpdateMachineCards_001">
- <E24B:DataArea>
- <E24B:UpdateMachineCards>
- <E24B:Machine>
- <E24B:Component>
  <f:ComponentSerNo xmlns:f="urn:fields">000000000000000456</f:ComponentSerNo> 
  <f:ComponentType xmlns:f="urn:fields">108</f:ComponentType> 
  </E24B:Component>
- <E24B:Market>
  <f:FinalMarket xmlns:f="urn:fields">TR</f:FinalMarket> 
  </E24B:Market>
  <f:SalesModel xmlns:f="urn:fields" /> 
  <f:SerialNo xmlns:f="urn:fields">000000000000000456</f:SerialNo> 
- <s:CntrolArea xmlns:s="urn:segments">
- <s:Bsr>
  <s:Noun>Machine Card</s:Noun> 
  <s:Verb>UPDATE</s:Verb> 
  </s:Bsr>
- <s:DateTime>
  <s:Dt_Qualifier>Creation</s:Dt_Qualifier> 
  <s:Dt_Value>20111207</s:Dt_Value> 
  <s:TimeZone>7200</s:TimeZone> 
-------------------------------------------------------------------------------


But this content is wrong.

The expected content should be as follows:



<?xml version="1.0" encoding="UTF-8" ?> 
- <E24B:E24B_Update_MachineCards_001 xmlns:E24B="urn:E24B_UpdateMachineCards_001" xmlns:f="urn:fields" xmlns:s="urn:segments"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <s:CntrolArea>
- <s:Bsr>
    
  <s:Verb>Update</s:Verb> 
    
  <s:Noun>Machine Card</s:Noun> 
    
-------------------------------------------------------------

Also xml content need to have multiple namespace. Can you help me please?

Nurhan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 01:03 PM

    Hi Nuhran,

    You can use either XSLT or JAVA mapping to add additional namespace

    In case of XSLT:

    Add the required namespace in the XSLT program and use copy Root node, this will copy the entire message

    In case of Java:

    Write a java program to consume the file and insert in line number 3 or 4 the required namespace

    After that you have your graphical mapping

    regards

    Ramesh

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2011 at 12:55 PM

    Hi,

    You can add additional namespaces using java/xslt mapping . Please go through this it may help you.

    Quick Tips: Dealing with Namespaces in XI/PI

    Regards,

    Priyanka

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 07, 2011 at 12:51 PM

    Hi Nurhan,

    You need java mapping or XSLT mapping to resolve the issue. Could you please kindly post the complete source XML and exact complete target XML. What is the version of PI you are working on?

    Regards

    Anupam

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      I used for target external definition and for prefix (E24B , f , s, instead of ns0, ns1..) i added module "AF_Modules/XMLAnonymizerBean".

      My source xml from is

      
      <?xml version="1.0" encoding="UTF-8"?>
      
      <ns0:MT_Machine_Update xmlns:ns0="http://xxx.com/MachineUpdate">
         <ControlArea>
            <Bsr>
               <Verb>13</Verb>
               <Noun>32</Noun>
            </Bsr>
            <Sender>
               <LogicalId>34124</LogicalId>
               <ReferenceId>124</ReferenceId>
            </Sender>
            <DateTime>
               <Dt_Qualifier>42</Dt_Qualifier>
               <Dt_Value>214</Dt_Value>
               <TimeZone>14</TimeZone>
            </DateTime>
         </ControlArea>
         <DataArea>
            <UpdateMachineCards>
               <CompanyCode>4325</CompanyCode>
               <CompanyName>325</CompanyName>
               <ManufacturerCode>352</ManufacturerCode>
               <ManufacturerName>53</ManufacturerName>
               <Machine>
                  <SalesModel>24</SalesModel>
                  <SerialNo>352</SerialNo>
                  <EnvironmentCode>53</EnvironmentCode>
                  <Market>
                     <FinalMarket>24</FinalMarket>
                     <NewCompanyCode></NewCompanyCode>
                  </Market>
                  <Component>
                     <ComponentType>23</ComponentType>
                     <PartNo>35</PartNo>
                     <Model>35</Model>
                     <ComponentSerNo>352</ComponentSerNo>
                  </Component>
               </Machine>
            </UpdateMachineCards>
         </DataArea>
      </ns0:MT_Machine_Update>
      

      The output should be as follows:

      <?xml version="1.0" encoding="UTF-8" ?> 
      - <E24B:E24B_Update_MachineCards_001 xmlns:E24B="urn:E24B_UpdateMachineCards_001" xmlns:f="urn:fields" xmlns:s="urn:segments" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      - <s:CntrolArea>
      - <s:Bsr>
          
        <s:Verb>Update</s:Verb> 
          
        <s:Noun>Machine Card</s:Noun> 
          
        </s:Bsr>
      - <s:Sender>
          
        <s:LogicalId>CWL</s:LogicalId> 
          
        <s:ReferenceId>2006-03-21T12:26:33</s:ReferenceId> 
          
        </s:Sender>
      - <s:DateTime>
          
        <s:Dt_Qualifier>Creation</s:Dt_Qualifier> 
          
        <s:Dt_Value>2006-03-24T14:29:46</s:Dt_Value> 
          
        <s:TimeZone>+02:00</s:TimeZone> 
          
        </s:DateTime>
          
        </s:CntrolArea>
      - <E24B:DataArea>
      - <E24B:UpdateMachineCards>
          
        <f:CompanyCode>428003</f:CompanyCode> 
          
        <f:CompanyName>VOLVO ÉPÍTÕGÉPEK HUNGÁRIA KERESKEDELMI KFT.</f:CompanyName> 
          
        <f:ManufacturerCode>CWL</f:ManufacturerCode> 
          
        <f:ManufacturerName>VOLVO COMPACT W</f:ManufacturerName> 
      - <E24B:Machine>
          
        <f:SalesModel>L45</f:SalesModel> 
          
        <f:SerialNo>19521</f:SerialNo> 
          
        <f:CurrentDate>20060323</f:CurrentDate> 
      - <E24B:Market>
          
        <f:FinalMarket>HU</f:FinalMarket> 
          
        </E24B:Market>
      - <E24B:Component>
          
        <f:ComponentType>17</f:ComponentType> 
          
        <f:PartNo>11305947</f:PartNo> 
          
        <f:ComponentSerNo>G070910121</f:ComponentSerNo> 
          
        </E24B:Component>
      - <E24B:Component>
          
        <f:ComponentType>66</f:ComponentType> 
          
        <f:PartNo>2814557</f:PartNo> 
          
        <f:ComponentSerNo>100710021</f:ComponentSerNo> 
          
        </E24B:Component>
          
        </E24B:Machine>
          
        </E24B:UpdateMachineCards>
          
        </E24B:DataArea>
          
        </E24B:E24B_Update_MachineCards_001>
      
      

      Thanks for your help

  • author's profile photo Former Member
    Former Member
    Posted on Dec 07, 2011 at 12:58 PM

    HI,

    Use the XSLT mapping after the message mapping in your operation mapping.

    Sample XSLT code is below.

    <?xml version="1.0" encoding="ISO-8859-1"?>

    <xsl:stylesheet version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns0="http://www.portal.fucapi.in">

    <xsl:template match="/">

    http://www.portal.fucapi.in" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.portal.fucapi.in http://alvaraes.gov.in:7778//jsp/importardados/NF.xsd">

    <xsl:attribute name = "nro">

    <xsl:value-of select = "/ns0:lote/@nro"/>

    </xsl:attribute>

    <xsl:element name="qtdeNF">

    <xsl:value-of select = "/ns0:lote/ns0:qtdeNF"/>

    </xsl:element>

    <notasFiscais>

    <xsl:for-each select="/ns0:lote/ns0:notasFiscais/ns0:notaFiscal">

    <xsl:copy-of select="/ns0:lote/ns0:notasFiscais/ns0:notaFiscal"/>

    </xsl:for-each>

    </notasFiscais>

    </lote>

    </xsl:template>

    </xsl:stylesheet>

    regards,

    ganesh.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.