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 » Getting to a XML element

Post new topic  Reply to topic
 Getting to a XML element « View previous topic :: View next topic » 
Author Message
WBI_user
PostPosted: Wed Jun 09, 2004 9:18 am    Post subject: Getting to a XML element Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

I am new to XLM namespace.
I have an incoming XML message which uses namespace.

I have a simple flow ith MQINPUT compute and MQOUTPUT

The XML is not defined to MRM. I just specify XMLNS as the type in the Input node.

The message looks like
<?xml version="1.0" encoding="UTF-8"?>
<mymsg xmlns="http://www.abc.com/TE/integration/" xmlns:abc="http://www.abc.com/TE/integration/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" xsi:schemaLocation="http://www.abc.com/TE/integration/ mymsg.xsd">
<Header>
<MessageId>d0a4ee0a3f3702129d26bc</MessageId>
<Timestamp>2004-05-31T13:08:07</Timestamp>
<Originator>my abcdefg</Originator>
<SequenceNumber>1</SequenceNumber>
</Header>
<Body>
<abc:Transaction xmlns="http://www.wxyz.org/MYDATA/namespace/" Version="1.0" xsi:type="MyTransactionView">
<StoreID>1234</StoreID>
:
<mymsg>
<Body>
<abc:Transaction>
<item>
<tender>
<AccountID>1234567</AccountID>
:
</tender>
</item>
</abc:Transaction>
</Body>
</mymsg>


I tried in my esql
DECLARE abc NAMESPACE 'http://www.abc.com/TE/integration/';
DECLARE AA CHAR

SET AA = InputRoot.XML.mymsg.Body.abc:Transaction.item.tender.AccountID ;

In the trace, I get a message saying fail to navigate to element.

POSLog.Body.abc:Transaction.LineItem.Tender.AccountID


I noticed that under Body it has another namespace definition
abc:Transaction

I tried to add
DECLARE abc:Transaction NAMESPACE 'http://www.wxyz.org/MYDATA/namespace/';
It does not like abc:Transaction


Can anyone help ?
Back to top
View user's profile Send private message
Hari
PostPosted: Wed Jun 09, 2004 9:29 am    Post subject: Reply with quote

Centurion

Joined: 21 Nov 2002
Posts: 117
Location: USA

Try this esql:

DECLARE abc NAMESPACE 'http://www.abc.com/TE/integration/';
DECLARE AA CHAR

SET AA = InputRoot.XMLNS.mymsg.Body.{abc}:Transaction.item.tender.AccountID ;

Just in case this returns a null value, modify the <mymsg> element in your input message to <mymsg xmlns=''">
Back to top
View user's profile Send private message
WBI_user
PostPosted: Wed Jun 09, 2004 10:08 am    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

Thanks for the quick response

DECLARE abc NAMESPACE 'http://www.abc.com/TE/integration/';
DECLARE AA CHAR

SET AA = InputRoot.XMLNS.mymsg.Body.{abc}:Transaction.item.tender.AccountID ;

Just put the {} around abc did not work

I also tried

SET AA='InputRoot.XML."mymsg xmlns='http://www.abc.com/TE/integration/' xmlns:abc= 'http://www.abc.com/TE/integration/'".Body.{abc}:Transaction.Item.Tender.AccountID'

I still got Failed to navigate to path element because it does not exist.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Jun 09, 2004 10:17 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Can you post a trace of the input message?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
Hari
PostPosted: Wed Jun 09, 2004 10:28 am    Post subject: Reply with quote

Centurion

Joined: 21 Nov 2002
Posts: 117
Location: USA

Also note the InputRoot.XMLNS instead of InputRoot.XML
Back to top
View user's profile Send private message
WBI_user
PostPosted: Wed Jun 09, 2004 3:35 pm    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

Here is my test case and error outputs.
I actually tried an element,MessageId which has no namespace prefix.
I am still not able to get to it. Just don't know what I did wrong.

Thanks in advance for your help

==== My input XML message ===================

<?xml version="1.0" encoding="UTF-8"?>
<MyMsg xmlns="http://www.abc.com/TE/" xmlns:abc="http://www.abc.com/TE/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Version="1.0" xsi:schemaLocation="http://www.abc.com/TE/MyMsg.xsd">
<Header>
<MessageId>1234567890</MessageId>
<Timestamp>2004-05-31T13:08:07</Timestamp>
<Originator>TransactionWorkflow</Originator>
<SequenceNumber>1</SequenceNumber>
</Header>
<Body>
<abc:Transaction xmlns="http://www.xyz.org/MyRetail/namespace/" Version="1.0" xsi:type="RetailXsactionView">
<RetailStoreID>BandQ.1</RetailStoreID>
</abc:Transaction>
</Body>
</MyMsg>


================

Try to get to element MessageId and RetailStoreID using the following esql

DECLARE abc NAMESPACE 'http://www.abc.com/TE/';
DECLARE AA CHAR;
DECLARE BB CHAR;
SET AA =InputRoot.XMLNS."MyMsg"."Header"."MessageId";
SET BB = InputRoot.XMLNS."MyMsg"."Body"."abc:Transaction".RetailStoreID;
SET OutputRoot.XML.mymsg.data1 = AA ;
SET OutputRoot.XML.mymsg.data2 = BB;
END;
===== Error reported by Trace output================

2004-06-09 19:29:08.769794 768 UserTrace BIP2537I: Node 'TEST_NS.Compute': Executing statement 'SET AA = InputRoot.XMLNS.MyMsg.Header.MessageId;' at (.TEST_NS_Compute.CopyMessageHeaders, 12.2).
2004-06-09 19:29:08.769858 768 UserTrace BIP2538I: Node 'TEST_NS.Compute': Evaluating expression 'InputRoot.XMLNS.MyMsg.Header.MessageId' at (.TEST_NS_Compute.CopyMessageHeaders, 12.10).
2004-06-09 19:29:08.769942 768 UserTrace BIP2543E: Node 'TEST_NS.Compute': (.TEST_NS_Compute.CopyMessageHeaders, 12.26) : Failed to navigate to path element because it does not exist.
2004-06-09 19:29:08.770053 768 UserTrace BIP2537I: Node 'TEST_NS.Compute': Executing statement 'SET BB = InputRoot.XMLNS.MyMsg.Body.abc:Transaction.RetailStoreID;' at (.TEST_NS_Compute.CopyMessageHeaders, 13.2).
2004-06-09 19:29:08.770121 768 UserTrace BIP2538I: Node 'TEST_NS.Compute': Evaluating expression 'InputRoot.XMLNS.MyMsg.Body.abc:Transaction.RetailStoreID' at (.TEST_NS_Compute.CopyMessageHeaders, 13.11).
2004-06-09 19:29:08.770187 768 UserTrace BIP2543E: Node 'TEST_NS.Compute': (.TEST_NS_Compute.CopyMessageHeaders, 13.27) : Failed to navigate to path element because it does not exist.

===Trace node output =============================
(0x01000010):XMLNS = (
(0x05000018):XML = (
(0x06000011): = '1.0'
(0x06000012): = 'UTF-8'
)
(0x06000002): = '
'
(0x01000000)http://www.abc.com/TE/:MyMsg = (
(0x07000012):xmlns = 'http://www.abc.com/TE/'
(0x07000012)xmlns:abc = 'http://www.abc.com/TE/'
(0x07000012)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'
(0x03000000):Version = '1.0'
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:schemaLocation = 'http://www.abc.com/TE/MyMsg.xsd'
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:Header = (
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:MessageId = (
(0x02000000): = '1234567890'
)
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:Timestamp = (
(0x02000000): = '2004-05-31T13:08:07'
)
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:Originator = (
(0x02000000): = 'TransactionWorkflow'
)
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:SequenceNumber = (
(0x02000000): = '1'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:Body = (
(0x02000000): = '
'
(0x01000000)http://www.abc.com/TE/:Transaction = (
(0x07000012):xmlns = 'http://www.xyz.org/MyRetail/namespace/'
(0x03000000):Version = '1.0'
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:type = 'RetailXsactionView'
(0x02000000): = '
'
(0x01000000)http://www.xyz.org/MyRetail/namespace/:RetailStoreID = (
(0x02000000): = 'BandQ.1'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
(0x02000000): = '
'
)
)
)
Back to top
View user's profile Send private message
shanson
PostPosted: Thu Jun 10, 2004 2:49 am    Post subject: Reply with quote

Partisan

Joined: 17 Oct 2003
Posts: 344
Location: IBM Hursley

In your schema, abc:Transaction itself defines a namespace for its children - you can also see this in the trace. So you need to additionally define a namespace constant for the wxyz prefix and use that in the ESQL path.

DECLARE wxyz NAMESPACE 'http://www.wxyz.org/MYDATA/namespace/';
SET BB = InputRoot.XMLNS."MyMsg"."Body"."abc:Transaction"."wxyz:RetailStoreID";
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu Jun 10, 2004 3:20 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

shanson wrote:
SET BB = InputRoot.XMLNS."MyMsg"."Body"."abc:Transaction"."wxyz:RetailStoreID";

The original poster may also need to qualify MyMsg and Body with the abc: namespace prefix.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
WBI_user
PostPosted: Thu Jun 10, 2004 5:56 am    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

I am really stuck. I just concentrate on getting the messageID and tried every combination with no luck. Here are my tests.
Test 1
DECLARE abc NAMESPACE 'http://www.abc.com/TE/';
SET AA=InputRoot.XMLNS.abc:MyMsg.abc:Header.abc:MessageId;

Test 2 - 7 are just combinations of moving the namespace prefix
SET AA=InputRoot.XMLNS.abc:MyMsg.abc:Header.MessageId;

SET AA=InputRoot.XMLNS.abc:MyMsg.Header.MessageId;

SET AA=InputRoot.XMLNS.MyMsg.Header.MessageId;

SET AA=InputRoot.XMLNS.MyMsg.Header.abc:MessageId;

SET AA=InputRoot.XMLNS.MyMsg.abc:Header.MessageId;

SET AA=InputRoot.XMLNS.MyMsg.abc:Header.abc:MessageId;

The trace output shows
==========================================
(0x01000010):XMLNS = (
(0x05000018):XML = (
(0x06000011): = '1.0'
(0x06000012): = 'UTF-8'
)
(0x01000000)http://www.abc.com/TE/:MyMsg = (
(0x07000012):xmlns = 'http://www.abc.com/TE/'
(0x07000012)xmlns:abc = 'http://www.abc.com/TE/'
(0x07000012)xmlns:xsi = 'http://www.w3.org/2001/XMLSchema-instance'
(0x03000000):Version = '1.0'
(0x03000000)http://www.w3.org/2001/XMLSchema-instance:schemaLocation = 'http://www.abc.com/TE/MyMsg.xsd'
(0x01000000)http://www.abc.com/TE/:Header = (
(0x01000000)http://www.abc.com/TE/:MessageId = (
(0x02000000): = '1234567890'
===========================================
XMLNS.abc:MyMsg.abc:Header.abc:MessageId should work.
Unless, I don't understand the trace correctly.
Back to top
View user's profile Send private message
shanson
PostPosted: Thu Jun 10, 2004 7:36 am    Post subject: Reply with quote

Partisan

Joined: 17 Oct 2003
Posts: 344
Location: IBM Hursley

If you have an XML schema for your message, create a msg set project and a msg set that specifies a runtime parser of XMLNS, then import your schema into the msg set. Ensure that the msg flow project references the msg set project (right click on the msg flow project then Properties->Project References) then you can use ESQL editor content assist to guide you through the ESQL creation.
Back to top
View user's profile Send private message
WBI_user
PostPosted: Thu Jun 10, 2004 7:58 am    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

The test message is just a heavily modified message so that I can show my problem here. The original message is much bigger and contains many schemas. So my answer to your comment is

Yes, I have a schema. However it contains a "union"
<xs:union memberTypes="MyEnumeration MyExtension"/>
This get rejected during message creation. The WBI help says that I can replace the uion with string. But does not say how.
I am new to XML schema.
I just tried
<xs:string memberTypes="MyEnumeration MyExtension"/>
and did not work. So I decided to just take the message in as generic well form XML instead of defining it to MRM.
Since you ask, can you provide soem help on "what does the book mean by replacing uion with string" ?
Back to top
View user's profile Send private message
shanson
PostPosted: Thu Jun 10, 2004 8:59 am    Post subject: Reply with quote

Partisan

Joined: 17 Oct 2003
Posts: 344
Location: IBM Hursley

Unions are not supported by the message model yet. It looks like your union is anonymous as it has no name, so two choices:
1) Either replace it with
<xs:simpleType>
<xs:restriction base="xs:string">
</xs:restriction>
</xs:simpleType>
2) Or delete the union and change the <xs:element> to add <type=xs:string>.
Back to top
View user's profile Send private message
WBI_user
PostPosted: Thu Jun 10, 2004 12:22 pm    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

I'll try to see if I can import the xsd.
But I still like to find out why it is not working with the esql statements
Back to top
View user's profile Send private message
ganeshkj
PostPosted: Fri Jun 18, 2004 3:23 am    Post subject: Reply with quote

Novice

Joined: 02 Jun 2004
Posts: 13
Location: Bangalore

Is the problem being resolved ?

What is the message domain being set to ? Is it being set to XML ?

Rgds
Ganesh
Back to top
View user's profile Send private message MSN Messenger
WBI_user
PostPosted: Thu Jun 24, 2004 6:29 am    Post subject: Reply with quote

Partisan

Joined: 07 Aug 2001
Posts: 386

Thanks for all the help. I got it working. I have to put the default namespace in front of every element that does not have a namespace prefix specified.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Getting to a XML element
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.