Author |
Message
|
Muthukrishnan |
Posted: Mon Jun 24, 2013 12:00 am Post subject: Accessing namespace from Input XML Message |
|
|
Apprentice
Joined: 16 Feb 2013 Posts: 48
|
Below is the input message received from application.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<SyncItemMaster xmlns="http://www.openapplications.org/oagis/9" xmlns:gic="http://www.gic.michelin.com/oagis/9/michelin/1">
<ApplicationArea>
<Sender>
<LogicalID>RAG</LogicalID>
</Sender>
<CreationDateTime>2013-06-14T07:50:32.309593</CreationDateTime>
<BODID>BMIAA0Q20130614055342355447</BODID>
</ApplicationArea>
<DataArea>
<gic:ItemMaster>
<gic:ItemMasterHeader>
<ItemID>
<ID schemeName="CAD">901334_106</ID>
<VariationID schemeName="CAI">901334</VariationID>
</ItemID>
<ItemStatus>
<Code>O</Code>
</ItemStatus>
<gic:UserArea name="CommercializationDate">2013-05-02</gic:UserArea>
<gic:UserArea name="LongDescription">7.50 R 16 LT 122/121L TL AGILIS MIAO CHN1 EXCEPT P743 RT</gic:UserArea>
<gic:UserArea name="UnitWeight">21.885</gic:UserArea>
<Classification type="Homologation Class">
<Codes>
<Code>I</Code>
</Codes>
</Classification>
</gic:ItemMasterHeader>
</gic:ItemMaster>
</DataArea>
</SyncItemMaster>
|
From the above input I need to access the attribute value of LongDescription available in UserArea element. I am unable to access the input along with XML namespace. I think I have missed something for the namespace. Please help to identify the gap.
Code: |
DECLARE xmlns NAMESPACE 'http://www.openapplications.org/oagis/9';
DECLARE gic NAMESPACE 'http://www.gic.michelin.com/oagis/9/michelin/1';
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.xmlns:SyncItemMaster.DataArea.ItemMaster;
DECLARE rowCnt INTEGER 0;
SET rowCnt = rowCnt+1;
IF LASTMOVE(itemMaster) THEN
SET OutputRoot.XMLNSC.root.row[rowCnt].Product_Info.tyreRim = THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:UserArea[] AS T where FIELDVALUE(T.(XMLNSC.Attribute)name)='LongDescription');
END IF;
END; |
|
|
Back to top |
|
 |
goffinf |
Posted: Mon Jun 24, 2013 12:11 am Post subject: Re: Accessing namespace from Input XML Message |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Muthukrishnan wrote: |
Below is the input message received from application.
Code: |
<?xml version="1.0" encoding="UTF-8"?>
<SyncItemMaster xmlns="http://www.openapplications.org/oagis/9" xmlns:gic="http://www.gic.michelin.com/oagis/9/michelin/1">
<ApplicationArea>
<Sender>
<LogicalID>RAG</LogicalID>
</Sender>
<CreationDateTime>2013-06-14T07:50:32.309593</CreationDateTime>
<BODID>BMIAA0Q20130614055342355447</BODID>
</ApplicationArea>
<DataArea>
<gic:ItemMaster>
<gic:ItemMasterHeader>
<ItemID>
<ID schemeName="CAD">901334_106</ID>
<VariationID schemeName="CAI">901334</VariationID>
</ItemID>
<ItemStatus>
<Code>O</Code>
</ItemStatus>
<gic:UserArea name="CommercializationDate">2013-05-02</gic:UserArea>
<gic:UserArea name="LongDescription">7.50 R 16 LT 122/121L TL AGILIS MIAO CHN1 EXCEPT P743 RT</gic:UserArea>
<gic:UserArea name="UnitWeight">21.885</gic:UserArea>
<Classification type="Homologation Class">
<Codes>
<Code>I</Code>
</Codes>
</Classification>
</gic:ItemMasterHeader>
</gic:ItemMaster>
</DataArea>
</SyncItemMaster>
|
From the above input I need to access the attribute value of LongDescription available in UserArea element. I am unable to access the input along with XML namespace. I think I have missed something for the namespace. Please help to identify the gap.
Code: |
DECLARE xmlns NAMESPACE 'http://www.openapplications.org/oagis/9';
DECLARE gic NAMESPACE 'http://www.gic.michelin.com/oagis/9/michelin/1';
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.xmlns:SyncItemMaster.DataArea.ItemMaster;
DECLARE rowCnt INTEGER 0;
SET rowCnt = rowCnt+1;
IF LASTMOVE(itemMaster) THEN
SET OutputRoot.XMLNSC.root.row[rowCnt].Product_Info.tyreRim = THE (SELECT ITEM FIELDVALUE(T) FROM itemMaster.*:ItemMasterHeader.*:UserArea[] AS T where FIELDVALUE(T.(XMLNSC.Attribute)name)='LongDescription');
END IF;
END; |
|
As a starting point, this reference is incorrect since the ItemMaster element is bound to the gic namespace :-
Code: |
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.xmlns:SyncItemMaster.DataArea.ItemMaster;
|
Personally I'd also avoid using xmlns as your defined prefix. It probably will work OK, but it just adds to the general confusion.
In your SELECT you also choose not to use the gic prefix binding. If you intend you use namespace agnostic statements then you may as well not bother declaring the binding.
Fraser. |
|
Back to top |
|
 |
Muthukrishnan |
Posted: Mon Jun 24, 2013 1:59 am Post subject: Accessing namespace from Input XML Message |
|
|
Apprentice
Joined: 16 Feb 2013 Posts: 48
|
Hi Fraser,
I am very well understand your first point. I am totally clueless on your second point. Please help to explain this.
Quote: |
In your SELECT you also choose not to use the gic prefix binding. If you intend you use namespace agnostic statements then you may as well not bother declaring the binding.
|
|
|
Back to top |
|
 |
kimbert |
Posted: Mon Jun 24, 2013 3:54 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
Personally I'd also avoid using xmlns as your defined prefix. |
I agree. The string 'xmlns' has a well-understood meaning in the XML world, but that is not the meaning that your code is using. I suggest that you use 'oagis9' as the prefix. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Jun 24, 2013 5:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Furthermore it seems that you have a default namespace (oasis9).
In WMB you need to prefix every element / node with the default namespace.
Code: |
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.oasis9:SyncItemMaster.oasis9:DataArea.gic:ItemMaster; |
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Muthukrishnan |
Posted: Mon Jun 24, 2013 7:00 pm Post subject: Accessing namespace from Input XML Message |
|
|
Apprentice
Joined: 16 Feb 2013 Posts: 48
|
Thanks a lot for your reply. . I will check this and let you know in case of any issues. |
|
Back to top |
|
 |
vishnurajnr |
Posted: Wed Jun 26, 2013 6:21 am Post subject: |
|
|
 Centurion
Joined: 08 Aug 2011 Posts: 134 Location: Trivandrum
|
Hi,
How about the below code
Code: |
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.*:SyncItemMaster.*:DataArea.*:ItemMaster;
SET attributeValue = THE(SELECT ITEM T FROM itemMaster.*:ItemMasterHeader.*:UserArea[] AS T WHERE T.(XMLNSC.Attribute)name = 'LongDescription'); |
 _________________ -------
A man is great by deeds, not by birth...! |
|
Back to top |
|
 |
|