|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
XML NAMESPACE ATTRIBUTE |
« View previous topic :: View next topic » |
Author |
Message
|
CAONIMA |
Posted: Mon Apr 06, 2015 12:57 pm Post subject: XML NAMESPACE ATTRIBUTE |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Hi all,
I have one question about XML NAMESPACE ATTRIBUTE.
My goal xml file is like:
Code: |
<DATA>
<XXSW_INV_IA_FG_T xmlns="http://xmlns.oracle.com/xdb/APPS" xmlns:obj1="http://xmlns.oracle.com/xdb/APPS">
<INVENTORY_ITEM_ID xmlns="">2896947</INVENTORY_ITEM_ID>
<ORGANIZATION_ID xmlns="">195</ORGANIZATION_ID>
<ORGANIZATION_CODE xmlns="">806</ORGANIZATION_CODE>
<ICC xmlns="">Finished Goods - CC</ICC>
<ITEM_TYPE xmlns="">FG</ITEM_TYPE>
<LEGACY_NUMBER xmlns=""/>
</XXSW_INV_IA_FG_T>
</DATA> |
But for right now, I only can get this:
Code: |
<DATA>
<XXSW_INV_IA_FG_T xmlns:obj1="http://xmlns.oracle.com/xdb/APPS" xmlns="http://xmlns.oracle.com/xdb/APPS">
<NS1:INVENTORY_ITEM_ID xmlns:NS1="">2896947</NS1:INVENTORY_ITEM_ID>
<NS2:ORGANIZATION_ID xmlns:NS2="">195</NS2:ORGANIZATION_ID>
<NS3:ORGANIZATION_CODE xmlns:NS3="">806</NS3:ORGANIZATION_CODE>
<NS4:ICC xmlns:NS4="">Finished Goods - CC</NS4:ICC>
<NS5:ITEM_TYPE xmlns:NS5="">FG</NS5:ITEM_TYPE>
<NS6:LEGACY_NUMBER xmlns:NS6=""></NS6:LEGACY_NUMBER>
</DATA> |
Here is my code:
Code: |
DECLARE INC INT 2;
DECLARE PNC INT CARDINALITY(InputRoot.DFDL.InputMessage.RECORD[]);
DECLARE REF1 reference to InputRoot.DFDL.InputMessage.RECORD[INC].*[1];
WHILE INC <= PNC DO
DECLARE space1 NAMESPACE 'http://xmlns.oracle.com/xdb/APPS';
CREATE LASTCHILD OF OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T TYPE XMLNSC.NamespaceDecl NAME 'xmlns:obj1' VALUE space1;
SET OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.(XMLNSC.NamespaceDecl)xmlns = space1;
WHILE LASTMOVE(REF1) DO
DECLARE NAME CHAR FIELDNAME(REF1);
DECLARE space2 NAMESPACE '';
CREATE LASTCHILD OF OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.space2:{NAME} TYPE XMLNSC.NamespaceDecl NAME 'xmlns' VALUE space2;
SET OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.space2:{NAME}= REF1;
MOVE REF1 NEXTSIBLING;
END WHILE;
SET INC = INC +1;
END WHILE;
|
How can I remove the 'NS1','NS2','NS3'..... at the beginning?
Thank you very much. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 07, 2015 4:44 am Post subject: Re: XML NAMESPACE ATTRIBUTE |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
CAONIMA wrote: |
Code: |
WHILE INC <= PNC DO
DECLARE space1 NAMESPACE 'http://xmlns.oracle.com/xdb/APPS';
CREATE LASTCHILD OF OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T TYPE XMLNSC.NamespaceDecl NAME 'xmlns:obj1' VALUE space1;
SET OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.(XMLNSC.NamespaceDecl)xmlns = space1;
WHILE LASTMOVE(REF1) DO
DECLARE NAME CHAR FIELDNAME(REF1);
DECLARE space2 NAMESPACE '';
CREATE LASTCHILD OF OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.space2:{NAME} TYPE XMLNSC.NamespaceDecl NAME 'xmlns' VALUE space2;
SET OutputRoot.XMLNSC.XXSE_INC_IA_FG_T.JMS_MSG.DATA.space1:XXSW_INV_IA_FG_T.space2:{NAME}= REF1;
MOVE REF1 NEXTSIBLING;
END WHILE;
SET INC = INC +1;
END WHILE;
|
|
This is just weird.
This:
Code: |
<DATA>
<XXSW_INV_IA_FG_T xmlns="http://xmlns.oracle.com/xdb/APPS" xmlns:obj1="http://xmlns.oracle.com/xdb/APPS">
<INVENTORY_ITEM_ID xmlns="">2896947</INVENTORY_ITEM_ID>
<ORGANIZATION_ID xmlns="">195</ORGANIZATION_ID>
<ORGANIZATION_CODE xmlns="">806</ORGANIZATION_CODE>
<ICC xmlns="">Finished Goods - CC</ICC>
<ITEM_TYPE xmlns="">FG</ITEM_TYPE>
<LEGACY_NUMBER xmlns=""/>
</XXSW_INV_IA_FG_T>
</DATA>
|
is even weirder. Why, exactly, does every tag have it's own blank namespace declaration and 2 apparently identical but unused namespace declarations at the top? What exactly is your requirement here, and why can you not use the more common:
Code: |
<DATA>
<XXSW_INV_IA_FG_T >
<INVENTORY_ITEM_ID xmlns="">2896947</INVENTORY_ITEM_ID>
<ORGANIZATION_ID>195</ORGANIZATION_ID>
<ORGANIZATION_CODE>806</ORGANIZATION_CODE>
<ICC>Finished Goods - CC</ICC>
<ITEM_TYPE>FG</ITEM_TYPE>
<LEGACY_NUMBER/>
</XXSW_INV_IA_FG_T>
</DATA>
|
which has the same content as your example? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
CAONIMA |
Posted: Tue Apr 07, 2015 6:05 am Post subject: |
|
|
Acolyte
Joined: 03 Dec 2014 Posts: 65
|
Thank you for your support, they just give me an example XML that I posted, and let me do the same one.
But for right now, it is Ok, they don't need me to add the blank xmlns Namespace on the XML.
Thank you very much. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 07, 2015 6:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
CAONIMA wrote: |
But for right now, it is Ok, they don't need me to add the blank xmlns Namespace on the XML. |
Never mind right now, they should never need you to add blank xmlns on the XML. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 07, 2015 7:57 am Post subject: Re: XML NAMESPACE ATTRIBUTE |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Vitor wrote: |
Why, exactly, does every tag have it's own blank namespace declaration and 2 apparently identical but unused namespace declarations at the top? What exactly is your requirement here, and why can you not use the more common:
Code: |
<DATA>
<XXSW_INV_IA_FG_T >
<INVENTORY_ITEM_ID xmlns="">2896947</INVENTORY_ITEM_ID>
<ORGANIZATION_ID>195</ORGANIZATION_ID>
<ORGANIZATION_CODE>806</ORGANIZATION_CODE>
<ICC>Finished Goods - CC</ICC>
<ITEM_TYPE>FG</ITEM_TYPE>
<LEGACY_NUMBER/>
</XXSW_INV_IA_FG_T>
</DATA>
|
which has the same content as your example? |
Not quite. The same thing would be
Code: |
<DATA>
<obj1:XXSW_INV_IA_FG_T xmlns:obj1="http://xmlns.oracle.com/xdb/APPS" >
<INVENTORY_ITEM_ID xmlns="">2896947</INVENTORY_ITEM_ID>
<ORGANIZATION_ID>195</ORGANIZATION_ID>
<ORGANIZATION_CODE>806</ORGANIZATION_CODE>
<ICC>Finished Goods - CC</ICC>
<ITEM_TYPE>FG</ITEM_TYPE>
<LEGACY_NUMBER/>
</obj1:XXSW_INV_IA_FG_T>
</DATA>
|
The reason for all the blank namespaces, was to signify that the children did not partake in the default namespace declared at the parent...
The way to make the NSx stuff go away is to declare a namespace declaration to be written out to your tree. Subsequent use of that namespace will then have the prefix declared to the tree. Alternatively you could inspect recursively the namespace and just remove it if it is blank.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|