ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing namespace from Input XML Message

Post new topic  Reply to topic
 Accessing namespace from Input XML Message « View previous topic :: View next topic » 
Author Message
Muthukrishnan
PostPosted: Mon Jun 24, 2013 12:00 am    Post subject: Accessing namespace from Input XML Message Reply with quote

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
View user's profile Send private message Send e-mail
goffinf
PostPosted: Mon Jun 24, 2013 12:11 am    Post subject: Re: Accessing namespace from Input XML Message Reply with quote

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
View user's profile Send private message
Muthukrishnan
PostPosted: Mon Jun 24, 2013 1:59 am    Post subject: Accessing namespace from Input XML Message Reply with quote

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
View user's profile Send private message Send e-mail
kimbert
PostPosted: Mon Jun 24, 2013 3:54 am    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Jun 24, 2013 5:18 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Muthukrishnan
PostPosted: Mon Jun 24, 2013 7:00 pm    Post subject: Accessing namespace from Input XML Message Reply with quote

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
View user's profile Send private message Send e-mail
vishnurajnr
PostPosted: Wed Jun 26, 2013 6:21 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Accessing namespace from Input XML Message
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.