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 » XML Parser (Not MRM) Accessing Elements

Post new topic  Reply to topic
 XML Parser (Not MRM) Accessing Elements « View previous topic :: View next topic » 
Author Message
PGoodhart
PostPosted: Tue Sep 14, 2004 10:08 am    Post subject: XML Parser (Not MRM) Accessing Elements Reply with quote

Master

Joined: 17 Jun 2004
Posts: 278
Location: Harrisburg PA

Guys,
Is it possible to access the values of XML elements using the XML parser?
When I try to access something using something like:
SET RQSValue = InputBody.ABC.RQS;
on an xml message like <ABC><RQS>AValue</RQS></ABC>
I keep getting back in the trace that the element doesn't exist.
If I examine the tree using trace and FIELDNAME it looks like:
InputBody.XML
and 7 other elements with blank namespaces
Does this make any sense?
If I do the same thing with the MRM-XML parser it works fine...
Thanks!
_________________
Patrick Goodhart
MQ Admin/Web Developer/Consultant
WebSphere Application Server Admin
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Sep 14, 2004 10:39 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

That should work.

Can we see your trace?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
PGoodhart
PostPosted: Tue Sep 14, 2004 11:21 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2004
Posts: 278
Location: Harrisburg PA

Apparently I oversimplified, because with the simple example I gave it worked.
The message I am attempting to read is a good deal more complicated.
The big difference seems to be that the root elements looks like:
<abc:def><rqs>AValue</rqs></abc:def>

And I have tried to go after it as
SET RQSValue = InputBody."abc:def".rqs;
and
SET RQSValue = InputBody.abc:def.rqs;
and
SET RQSValue = InputBody.*[>].rqs; (which is what I really want)
and
SET RQSValue = InputBody.abc.rqs;
and
SET RQSValue = InputBody.def.rqs;

And then I ran into the problems...
I am going to try to replicate it again and get a good trace.
_________________
Patrick Goodhart
MQ Admin/Web Developer/Consultant
WebSphere Application Server Admin
Back to top
View user's profile Send private message
PGoodhart
PostPosted: Tue Sep 14, 2004 11:29 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2004
Posts: 278
Location: Harrisburg PA

with "ABC:DEF" and SET RQSValue = InputBody."ABC:DEF".RQS; and message like:
<?xml version="1.0" encoding="UTF-8"?>
<ABC:DEF><RQS>AValue</RQS></ABC:DEF>

2004-09-14 15:25:21.003440 5914 UserTrace BIP2537I: Node 'ABC.ABCFlow.Co
mpute': Executing statement 'DECLARE RQSValue CHARACTER '';' at (ABC.ABCFlow_Com
pute.CopyEntireMessage, 2.3).
2004-09-14 15:25:21.003503 5914 UserTrace BIP2537I: Node 'ABC.ABCFlow.Co
mpute': Executing statement 'SET RQSValue = InputBody.ABC:DEF.RQS;' at (ABC.ABCF
low_Compute.CopyEntireMessage, 3.3).
2004-09-14 15:25:21.003534 5914 UserTrace BIP2538I: Node 'ABC.ABCFlow.Co
mpute': Evaluating expression 'InputBody.ABC:DEF.RQS' at (ABC.ABCFlow_Compute.Co
pyEntireMessage, 3.1.
2004-09-14 15:25:21.003889 5914 UserTrace BIP2543E: Node 'ABC.ABCFlow.Co
mpute': (ABC.ABCFlow_Compute.CopyEntireMessage, 3.2 : Failed to navigate to pa
th element because it does not exist.
_________________
Patrick Goodhart
MQ Admin/Web Developer/Consultant
WebSphere Application Server Admin
Back to top
View user's profile Send private message
TonyD
PostPosted: Tue Sep 14, 2004 3:09 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

There are several difficulties with the examples you have shown. 'ABC:' denotes a namesapace. You must use the XMLNS, or MRM, parsers for such messages. The ESQL reference should therefore be of the type (from one of your examples):

Code:
SET RQSValue = InputBody.XMLNS.abc:def.rqs;


Also, case is critical so the above should really be:

Code:
SET RQSValue = InputBody.XMLNS.ABC:DEF.RQS;


However, this would still be invalid. In addition, your message should have an 'xmlns' declaration for the root element (not shown in your example?):

Code:
<ABCMSG xmlns:ABC="http://abc.com/ABC-2004/09/0102"...
<DEF>
<RQS>AValue</RQS>
</DEF>
</ABCMSG>


If your message is reconstructed as above, the SET statement would be:

Code:
SET RQSValue = InputBody.XMLNS.ABC:ABCMSG.ABC:DEF.ABC:RQS;


Alternatively, if you do not specify a namespace 'prefix' the message would be:

Code:
<ABCMSG xmlns="http://abc.com/ABC-2004/09/0102"...
<DEF>
<RQS>AValue</RQS>
</DEF>
</ABCMSG>

: and the ESQL would not require 'ABC:' to be specified:

Code:
SET RQSValue = InputBody.XMLNS.ABCMSG.DEF.RQS;
Back to top
View user's profile Send private message Send e-mail
jefflowrey
PostPosted: Tue Sep 14, 2004 3:48 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

I think you mean "InputRoot.XMLNS", as "InputBody.XMLNS" would be "InputRoot.XMLNS.XMLNS" if the last child of the InputRoot was the XMLNS parser sub-tree.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
TonyD
PostPosted: Wed Sep 15, 2004 3:35 am    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Of course... I should have looked more closely at the example! ...was distracted by the other errors. Apologies...
Back to top
View user's profile Send private message Send e-mail
PGoodhart
PostPosted: Wed Sep 15, 2004 5:58 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2004
Posts: 278
Location: Harrisburg PA

Number 1. Yes I know case matters. I was trying to write an example that doesn't expose anything sensitive. And if you notice I did change the case on my second message so the examples do match.
Number 2. I can't use namespaces as the namespaces are on a remote server, and the broker is isolated from the internet. Any realistic suggestions?
Number 3. Got it working in the XML as ABC:DEF. So apparently it can work that way.

Bottom Line: The broker was sick and needed to have some bad (rouge) execution groups deleted from the database table BROKERAAEG. That and very careful definitions cleared up the problems.

New Question: However the *[1] and *[>] don't seem to work as expect in the XML parser.
If I have an XML message like:
<ABC:DEF><A><B>BValue</B></A><C>CValue</C></ABC:DEF>
and I want to get the value of the <B> element why can't I do the following?
DECLARE AValue AS CHARACTER;
SET AValue = InputBody.*[1].*[1];
_________________
Patrick Goodhart
MQ Admin/Web Developer/Consultant
WebSphere Application Server Admin
Back to top
View user's profile Send private message
TonyD
PostPosted: Wed Sep 15, 2004 2:52 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Quote:
Number 2. I can't use namespaces as the namespaces are on a remote server, and the broker is isolated from the internet. Any realistic suggestions?


I'm not sure what you mean by the above. If elements in an XML message have namespace prefixes the broker will successfully resolve them so long as there is a corresponding 'xmlns:prefix' declaration. No reference to a remote server is required.
Back to top
View user's profile Send private message Send e-mail
TonyD
PostPosted: Wed Sep 15, 2004 5:22 pm    Post subject: Reply with quote

Knight

Joined: 15 May 2001
Posts: 540
Location: New Zealand

Further to my earlier reply, I am not sure whether you plan to use namespaces or not.
However, this message:
Code:
<ABC:DEF xmlns:ABC="http://ABC-2004-09-16">
 <ABC:A>
  <ABC:B>BValue</ABC:B>
 </ABC:A>
 <ABC:C>CValue</ABC:C>
</ABC:DEF>

:submitted to this ESQL:
Code:

      DECLARE ABC NAMESPACE 'http://ABC-2004-09-16';
      DECLARE AValue  CHARACTER;
      SET AValue = InputRoot.XMLNS.ABC:DEF.*[2].*[1];
      SET OutputRoot.XML.Msg.AValue = AValue;

:delivers this output:
Code:

<Msg>
 <AValue>BValue</AValue>
</Msg>

Alternatively, this message:
Code:

<DEF xmlns="http://ABC-2004-09-16">
 <A>
  <B>BValue</B>
 </A>
 <C>CValue</C>
</DEF>

:passed to this ESQL:
Code:

      DECLARE AValue  CHARACTER;
      DECLARE A INTEGER CARDINALITY(InputRoot.XMLNS."http://ABC-2004-09-16":DEF.*[]);
      DECLARE B INTEGER CARDINALITY(InputRoot.XMLNS."http://ABC-2004-09-16":DEF.*[2].*[]);
      SET AValue = InputRoot.XMLNS."http://ABC-2004-09-16":DEF.*[2].*[1];
      SET OutputRoot.XML.Msg.AValue = AValue;

:also produces this output:
Code:

<Msg>
 <AValue>BValue</AValue>
</Msg>

The 'xmlns' declaration is seen as a child of 'DEF' and therefore element 'A' is child # 2.
If namespaces are used, the broker requires all elements to be suitably qualified in the ESQL.
Back to top
View user's profile Send private message Send e-mail
PGoodhart
PostPosted: Thu Sep 16, 2004 3:57 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2004
Posts: 278
Location: Harrisburg PA

Thanks Tony,
You showed me what I was doing wrong.
I wasn't working with the namespaces properly, and that was exactly what you showed me. Kudos!
_________________
Patrick Goodhart
MQ Admin/Web Developer/Consultant
WebSphere Application Server Admin
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 » XML Parser (Not MRM) Accessing Elements
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.