on 07-20-2009 2:27 AM
I am working on a RFC to JMS scenario and am having trouble getting the XML in the required format. I have loaded the XML file provided in my mapping. However the result was not what I had anticipated.
<br>
This is the XML provided and what I want to produce:
<br>
<
?xml version="1.0" encoding="UTF-8" ?> <br>
<MyNS3:Maint_Struc <br>
xmlns:MyNS1="http://www.MyTest.com/My_Namespace/Part1" <br>
xmlns:MyNS2="http://www.MyTest.com/My_Namespace/Part2" <br>
xmlns:MyNS5="http://www.MyTest.com/My_Namespace/Part5" <br>
xmlns:MyNS3="http://www.MyTest.com/My_Namespace/Part3" <br>
xmlns:MyNS4="http://www.MyTest.com/My_Namespace/Part4" <br>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <br>
xsi:schemaLocation="www.MyTest.com/My_Namespace/Part3 file:/C:/MyStructure.xsd">
<br>
<
MyNS2:SubStruc_1> <br>
<
MyNS2:Fld_1_1_A>Value001<
/MyNS2:Fld_1_1_A> <br>
<
MyNS2:Fld_1_1_B>Value002<
/MyNS2:Fld_1_1_B> <br>
<
/MyNS2:SubStruc_1> <br>
<br>
<
MyNS3:SubStruc_2> <br>
<
MyNS1:SubStruc_2_1> <br>
<
MyNS1:Fld_2_1_A>Value003<
/MyNS1:Fld_2_1_A> <br>
<
MyNS1:Fld_2_1_B>Value004<
/MyNS1:Fld_2_1_B> <br>
<
/MyNS1:SubStruc_2_1> <br>
<
MyNS4:Fld_2_A>Value005<
/MyNS4:Fld_2_A> <br>
<
MyNS4:Fld_2_B>Value006<
/MyNS4:Fld_2_B> <br>
<
/MyNS3:SubStruc_2> <br>
<br>
<
MyNS3:SubStruc_3> <br>
<
MyNS5:SubStruc_3_1> <br>
<
MyNS5:Fld_3_1_A>Value007<
/MyNS5:Fld_3_1_A> <br>
<
MyNS5:Fld_3_1_B>Value008<
/MyNS5:Fld_3_1_B> <br>
<
/MyNS5:SubStruc_3_1> <br>
<
MyNS3:Fld_3_A>Value009<
/MyNS3:Fld_3_A> <br>
<
MyNS5:Fld_3_B>Value010<
/MyNS5:Fld_3_B> <br>
<
MyNS2:Fld_3_C>Value011<
/MyNS2:Fld_3_C> <br>
<
/MyNS3:SubStruc_3> <br>
<
/MyNS3:Maint_Struc> <br>
<br>
However I am getting the following when mapped: <br>
<
?xml version="1.0" encoding="UTF-8"?> <br>
<
ns0:Maint_Struc <br>
xmlns:MyNS4="http://www.MyTest.com/My_Namespace/Part4" <br>
xmlns:MyNS5="http://www.MyTest.com/My_Namespace/Part5" <br>
xmlns:MyNS2="http://www.MyTest.com/My_Namespace/Part2" <br>
xmlns:MyNS1="http://www.MyTest.com/My_Namespace/Part1" <br>
xmlns:ns0="http://www.MyTest.com/My_Namespace/Part3" <br>
xmlns:ns1="http://www.w3.org/2001/XMLSchema-instance" <br>
ns1:schemaLocation="www.MyTest.com/My_Namespace/Part3 file:/C:/MyStructure.xsd"> <br>
<
ns2:SubStruc_1 xmlns:ns2="http://www.MyTest.com/My_Namespace/Part2"> <br>
<
ns2:Fld_1_1_A>Value001<
/ns2:Fld_1_1_A> <br>
<
ns2:Fld_1_1_B>Value002<
/ns2:Fld_1_1_B> <br>
<
/ns2:SubStruc_1> <br>
<br>
<
ns0:SubStruc_2> <br>
<
ns3:SubStruc_2_1 xmlns:ns3="http://www.MyTest.com/My_Namespace/Part1"> <br>
<
ns3:Fld_2_1_A>Value003<
/ns3:Fld_2_1_A> <br>
<
ns3:Fld_2_1_B>Value004<
/ns3:Fld_2_1_B> <br>
<
/ns3:SubStruc_2_1> <br>
<
ns4:Fld_2_A xmlns:ns4="http://www.MyTest.com/My_Namespace/Part4">Value005<
/ns4:Fld_2_A> <br>
<
ns4:Fld_2_B xmlns:ns4="http://www.MyTest.com/My_Namespace/Part4">Value006<
/ns4:Fld_2_B> <br>
<
/ns0:SubStruc_2> <br>
<br>
<
ns0:SubStruc_3> <br>
<
ns5:SubStruc_3_1 xmlns:ns5="http://www.MyTest.com/My_Namespace/Part5"> <br>
<
ns5:Fld_3_1_A>Value007<
/ns5:Fld_3_1_A> <br>
<
ns5:Fld_3_1_B>Value008<
/ns5:Fld_3_1_B> <br>
<
/ns5:SubStruc_3_1> <br>
<
ns0:Fld_3_A>Value009<
/ns0:Fld_3_A> <br>
<
ns5:Fld_3_B xmlns:ns5="http://www.MyTest.com/My_Namespace/Part5">Value010<
/ns5:Fld_3_B> <br>
<
ns2:Fld_3_C xmlns:ns2="http://www.MyTest.com/My_Namespace/Part2">Value011<
/ns2:Fld_3_C> <br>
<
/ns0:SubStruc_3> <br>
<
/ns0:Maint_Struc> <br>
<br>
Things that are wrong with the mapped XML: <br>
- the namespace "http://www.MyTest.com/My_Namespace/Part3" was prefixed with MyNS3 but XI reassigned it to ns0
<br>- original prefixes are not used in the element tags <br>
<br>
Appreciate if anyone can help. <br>
Thanks.
If you want to keep the original namespace prefixes then try the use of XSLT mapping
In XSLT you can specify the prefix which needs to be associated with the corresponding namespace...you need to ensure that the same relation is maintained throughout the mapping......
Regards,
Abhishek.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank You All.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for all your valuable suggestions. Does any know why XI/PI does not acknowledge/use the namespace prefix that is defined in the XML? Is there no other way around this short-coming apart from using XSLT mapping?
<br>
I did try using the anonymizer (as suggested by Manjusha). With the anonymizer I am able to change the namespace prefix in the element tags to the way I want it. However the namespace definition is still showing in the element tag.
<br>
<MyNS2:SubStruc_1 xmlns:MyNS2="http://www.MyTest.com/My_Namespace/Part2"> <br>
<MyNS2:Fld_1_1_A>Value001</MyNS2:Fld_1_1_A> <br>
<MyNS2:Fld_1_1_B>Value002</MyNS2:Fld_1_1_B> <br>
</MyNS2:SubStruc_1> <br>
<br>
This is almost perfect only if I am able to remove the definition xmlns:MyNS2="http://www.MyTest.com/My_Namespace/Part2" from the element tag. Suggestion any one?
Thanks All.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> Does any know why XI/PI does not acknowledge/use the namespace prefix that is defined in the XML?
Because namespace prefixes can be choosed freely. It is no difference, what prefix is used. The XML document is semantically equal.
It the receiver requests a fixed namespace, then the parser of the receiver behaves wrong.
Regards
Stefan
Please check if this helps:
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
Regards,
Manjusha.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi. peppa
I agree with guys , you need to use an XSLT , XI always asigned the prefix ns0 , ns1...etc.
So if you need to change your prefix use an XSLT.
Please check the links.
One more site where you can get all the XSLT-related information:
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.