|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Unable to retrieve child elements in XML |
« View previous topic :: View next topic » |
Author |
Message
|
Muthukrishnan |
Posted: Fri May 31, 2013 2:00 am Post subject: Unable to retrieve child elements in XML |
|
|
Apprentice
Joined: 16 Feb 2013 Posts: 48
|
Hi,
I am trying to retrieve one of the child elements in the XML. The requirement is to check for an element for a particular child in the XML as 'Name' and another child element with Attribute as 'Country'.
Below is the input xml tree
I need to fetch the Name if Location Attribute is "Country"
Code: |
<SyncItemMaster>
<ApplicationArea>
<DataArea>
<ItemMaster>
<ItemMasterHeader>
<OwnerParty category="CUSTOMER">
<Location>
<UserArea>
<StartDate>2009-01-01</StartDate>
<EndDate>2011-09-15</EndDate>
</UserArea>
</Location>
</OwnerParty>
<OwnerParty>
<Name>001</Name>
<Location Type="COUNTRY"/>
</OwnerParty>
</ItemMaster>
</ItemMasterHeader>
</DataArea>
</ApplicationArea>
</SyncItemMaster>
|
here is what I am trying to get the value
Code: |
SET OutputRoot.XMLNSC.root.row[rowCnt].Product_Info.rpc = THE (SELECT ITEM THE(SELECT ITEM itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name FROM T.*:OwnerParty[] AS C WHERE C.Location.(XMLNSC.Attribute)Type = 'COUNTRY' ) FROM itemMaster.*:ItemMasterHeader[] AS T );
|
here is debug log
Code: |
2013-05-31 17:23:25.401292 8688 UserTrace BIP2537I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Executing statement ''SET OutputRoot.XMLNSC.root.row[rowCnt].Product_Info.rpc = THE (SELECT ITEM THE (SELECT ITEM itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name FROM T.*:OwnerParty[ ] AS C WHERE C.Location.(XMLNSC.Attribute)Type = 'COUNTRY') FROM itemMaster.*:ItemMasterHeader[ ] AS T);'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.4').
2013-05-31 17:23:25.401321 8688 UserTrace BIP2538I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''THE (SELECT ITEM THE (SELECT ITEM itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name FROM T.*:OwnerParty[ ] AS C WHERE C.Location.(XMLNSC.Attribute)Type = 'COUNTRY') FROM itemMaster.*:ItemMasterHeader[ ] AS T)'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.62').
2013-05-31 17:23:25.401346 8688 UserTrace BIP2572W: Node: 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.62') : Finding one and only SELECT result.
2013-05-31 17:23:25.401407 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''itemMaster.*:ItemMasterHeader[ ]'' at ('.WMB_9D1_PROD_SUB00_001.Main', '156.9'). This resolved to ''itemMaster.*:ItemMasterHeader[]''. The result was ''LIST... First Element Type=16777216 NameSpace='' Name='ItemMasterHeader' Value=NULL''.
2013-05-31 17:23:25.401460 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''rowCnt'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.35'). This resolved to ''rowCnt''. The result was ''1''.
2013-05-31 17:23:25.401496 8688 UserTrace BIP2538I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''THE (SELECT ITEM itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name FROM T.*:OwnerParty[ ] AS C WHERE C.Location.(XMLNSC.Attribute)Type = 'COUNTRY')'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.79').
2013-05-31 17:23:25.401519 8688 UserTrace BIP2572W: Node: 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.79') : Finding one and only SELECT result.
2013-05-31 17:23:25.401559 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''T.*:OwnerParty[ ]'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.150'). This resolved to ''T.*:OwnerParty[]''. The result was ''LIST... First Element Type=16777216 NameSpace='' Name='OwnerParty' Value=NULL''.
2013-05-31 17:23:25.401597 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.401628 8688 UserTrace BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '155.10') : Failed to navigate to path element number '3' because it does not exist.
2013-05-31 17:23:25.401660 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.401687 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.10'). This resolved to ''C.Location.(50331904)Type''. The result was ''EMPTY ROW''.
2013-05-31 17:23:25.401716 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type = 'COUNTRY''' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.44'). This resolved to ''EMPTY ROW = 'COUNTRY'''. The result was ''NULL''.
2013-05-31 17:23:25.401742 8688 UserTrace BIP2569W: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.79') : WHERE clause evaluated to false or unknown. Iterating FROM clause.
2013-05-31 17:23:25.401777 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.401815 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.401845 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.10'). This resolved to ''C.Location.(50331904)Type''. The result was ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='COUNTRY'''.
2013-05-31 17:23:25.401880 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type = 'COUNTRY''' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.44'). This resolved to ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='COUNTRY' = 'COUNTRY'''. The result was ''TRUE''.
2013-05-31 17:23:25.401910 8688 UserTrace BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.95') : Failed to navigate to path element number '4' because it does not exist.
2013-05-31 17:23:25.401941 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.95'). This resolved to ''itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name''. The result was ''EMPTY ROW''.
2013-05-31 17:23:25.401983 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''T.*:OwnerParty[ ]'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.150'). This resolved to ''T.*:OwnerParty[]''. The result was ''LIST... First Element Type=16777216 NameSpace='' Name='OwnerParty' Value=NULL''.
2013-05-31 17:23:25.402021 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.402051 8688 UserTrace BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '155.10') : Failed to navigate to path element number '3' because it does not exist.
2013-05-31 17:23:25.402082 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.402109 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.10'). This resolved to ''C.Location.(50331904)Type''. The result was ''EMPTY ROW''.
2013-05-31 17:23:25.402135 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type = 'COUNTRY''' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.44'). This resolved to ''EMPTY ROW = 'COUNTRY'''. The result was ''NULL''.
2013-05-31 17:23:25.402162 8688 UserTrace BIP2569W: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.79') : WHERE clause evaluated to false or unknown. Iterating FROM clause.
2013-05-31 17:23:25.402194 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.402231 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''XMLNSC.Attribute'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.22'). This resolved to ''XMLNSC.Attribute''. The result was ''1095266992384''.
2013-05-31 17:23:25.402263 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type'' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.10'). This resolved to ''C.Location.(50331904)Type''. The result was ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='COUNTRY'''.
2013-05-31 17:23:25.402296 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''C.Location.(XMLNSC.Attribute)Type = 'COUNTRY''' at ('.WMB_9D1_PROD_SUB00_001.Main', '155.44'). This resolved to ''ROW... Root Element Type=50331904 NameSpace='' Name='Type' Value='COUNTRY' = 'COUNTRY'''. The result was ''TRUE''.
2013-05-31 17:23:25.402326 8688 UserTrace BIP2543I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': ('.WMB_9D1_PROD_SUB00_001.Main', '154.95') : Failed to navigate to path element number '4' because it does not exist.
2013-05-31 17:23:25.402355 8688 UserTrace BIP2539I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Evaluating expression ''itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name'' at ('.WMB_9D1_PROD_SUB00_001.Main', '154.95'). This resolved to ''itemMaster.*:ItemMasterHeader.*:OwnerParty.*:Name''. The result was ''EMPTY ROW''.
2013-05-31 17:23:25.402399 8688 UserTrace BIP2567I: Node 'WMB_9D1_PROD_SUB00_001.9D1_PROD': Assigning NULL to ''OutputRoot.XMLNSC.root.row[rowCnt].Product_Info.rpc'', thus deleting it. |
|
|
Back to top |
|
 |
kash3338 |
Posted: Fri May 31, 2013 2:45 am Post subject: |
|
|
Shaman
Joined: 08 Feb 2009 Posts: 709 Location: Chennai, India
|
Couple of observations,
Firstly the given sample XML is invalid. Hope this is not the one you have used for testing. The tags ItemMaster and ItemMasterHeader are not closed in a proper order.
Secondly, the query you have used looks too complicated for a simple select. From your inputs it looks like you need to select the Name where Location Type is "COUNTRY" under the element OwnerParty. If this is the query you need, a simple select like below would be suffic,
Code: |
DECLARE itemMaster REFERENCE TO InputRoot.XMLNSC.SyncItemMaster.ApplicationArea.DataArea.ItemMaster;
THE(SELECT ITEM T.Name FROM itemMaster.ItemMasterHeader.OwnerParty[] AS T WHERE T.Location.(XMLNSC.Attribute)Type = 'COUNTRY'); |
|
|
Back to top |
|
 |
mqceries |
Posted: Mon Jun 10, 2013 1:36 pm Post subject: |
|
|
 Acolyte
Joined: 02 Dec 2011 Posts: 70
|
very nicely constructed the xquery Kash3338 . OP hope this helped you, let us know. |
|
Back to top |
|
 |
Muthukrishnan |
Posted: Wed Jun 12, 2013 11:39 pm Post subject: |
|
|
Apprentice
Joined: 16 Feb 2013 Posts: 48
|
Thanks a lot for your reply. Please mark this as closed. |
|
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
|
|
|
|