on 12-16-2013 4:22 PM
I have data types with different namespaces and I want to show them in the root element of the outgoing file.
In every data type I set the value of "Qualify Schema" to "Elements & Attributes".
With this the created file has only the XML Namespace of the message type in the root element as nw0. The other namespaces ns1..ns5 are created on every element. It looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders>
<ns0:Customer>
<ns1:Name xmlns:ns1="http://xxx.Customer">My Name</ns1:Name>
<ns1:Address xmlns:ns1="http://xxx.Customer">My Address</ns1:Address>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns3:Article xmlns:ns3="http://xxx.Article">My Article</ns3:Article>
<ns3:Description xmlns:ns3="http://xxx.Article">My Description</ns3:Description>
</ns0:Item>
</ns0:Item>
</ns0:Items>
</ns0:Order>
Can PI create a message with several namespaces in the root element. What I want to have is this:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders
xmlns:ns1="http://xxx.Customer"
xmlns:ns3="http://xxx.Article">
<ns0:Customer>
<ns1:Name>My Name</ns1:Name>
<ns1:Address>My Address</ns1:Address>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns3:Article>My Article</ns3:Article>
<ns3:Description>My Description</ns3:Description>
</ns0:Item>
</ns0:Item>
</ns0:Items>
</ns0:Order>
Hi Michael,
With XSL you can do it in a few lines.
With Input:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders">
<ns0:Customer>
<ns1:Name xmlns:ns1="http://xxx.Customer">My Name</ns1:Name>
<ns1:Address xmlns:ns1="http://xxx.Customer">My Address</ns1:Address>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns3:Article xmlns:ns3="http://xxx.Article">My Article</ns3:Article>
<ns3:Description xmlns:ns3="http://xxx.Article">My Description</ns3:Description>
</ns0:Item>
</ns0:Items>
</ns0:Order>
You use this XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="./child::*">
<ns0:Order xmlns:ns0="http://xxx.Orders" xmlns:ns1="http://xxx.Customer" xmlns:ns3="http://xxx.Article">
<xsl:copy-of select="*"/>
</ns0:Order>
</xsl:template>
</xsl:stylesheet>
You wil get this output:
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders" xmlns:ns1="http://xxx.Customer" xmlns:ns3="http://xxx.Article">
<ns0:Customer>
<ns1:Name xmlns:ns1="http://xxx.Customer">My Name</ns1:Name>
<ns1:Address xmlns:ns1="http://xxx.Customer">My Address</ns1:Address>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns3:Article xmlns:ns3="http://xxx.Article">My Article</ns3:Article>
<ns3:Description xmlns:ns3="http://xxx.Article">My Description</ns3:Description>
</ns0:Item>
</ns0:Items>
</ns0:Order>
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
You can use Java mapping to achieve this requirement.
Regards,
Pranav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
PI graphical mapping can not merge all the namespace into root node, you need to use XSLT or Java map to achieve that.
I would like to know why you want to merge all the namespace to root node?
Regards,
Harish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Michael,
You can try with having external definition as a target structure in your map. External definition root needs to define with all the required target namespace.
The only problem is if one of the node is option and did not populate in the structure, then also you will get all the namespace.
I never tried this, but i hope this will work.
Regards,
Harish
Hello Michael,
Using graphical mapping, PI can only support one namespace in a root node. The other namespaces get "distributed" to their respective fields. Having said that,
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders" xmlns:ns1="http://xxx.Customer" xmlns:ns2="http://xxx.Article">
<ns0:Customer>
<ns1:Name/>
<ns1:Address/>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns2:Article/>
<ns2:Description/>
</ns0:Item>
</ns0:Items>
</ns0:Order>
and
<?xml version="1.0" encoding="UTF-8"?>
<ns0:Order xmlns:ns0="http://xxx.Orders>
<ns0:Customer>
<ns1:Name xmlns:ns1="http://xxx.Customer">My Name</ns1:Name>
<ns1:Address xmlns:ns1="http://xxx.Customer">My Address</ns1:Address>
</ns0:Customer>
<ns0:Items>
<ns0:Item>
<ns3:Article xmlns:ns3="http://xxx.Article">My Article</ns3:Article>
<ns3:Description xmlns:ns3="http://xxx.Article">My Description</ns3:Description>
</ns0:Item>
</ns0:Item>
</ns0:Items>
</ns0:Order>
are semantically equivalent, although the first one is cleaner. Maybe this blog would help since it uses UDF to assign namespaces:
Hope this helps,
Mark
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.