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 » Namespaces and attributes

Post new topic  Reply to topic
 Namespaces and attributes « View previous topic :: View next topic » 
Author Message
RichA
PostPosted: Thu Mar 19, 2015 2:54 am    Post subject: Namespaces and attributes Reply with quote

Centurion

Joined: 14 Mar 2002
Posts: 102

Hi, I've got some message broker code which I am debugging and it seems to be interpreting some xml in an unexpected way.

So, it's reasonably complex, the message itself is made up of three layers, each layer being xml, the base payload of the message is double escaped, then there's a wrapper around that which is single escaped and that sits within the unescaped outer wrapper.

There's validation of the outer wrapper which is working fine, we then take the element containing the single escaped wrapper and parse it using
CREATE LASTCHILD OF Environment.Layer DOMAIN ('MRM') PARSE(PAYLOAD SET 'DataSet' TYPE 'DataRequest' FORMAT 'XML' CCSID 1208);

Now when I'm debugging I see the MRM tree has been constructed an it looks fine, to an extent....

The root element has two attributes, and if the message is formatted in one way those attributes appear to be interpreted as elements, if the message is formatted in another way then the attributes appear to be interpreted as attributes this is causing me validation problems further on in the code.

So, if I capture the messages before parsing into the XML tree the element being parsed looks like -

Message 1 -
<?xml version="1.0" encoding="UTF-8"?><Data xmlns="http://schemas.blah.co.uk/common/operations" xmlns:entity="http://schemas.blah.co.uk/common/businessentities" xmlns:type="http://schemas.blah.co.uk/common/businesstypes"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VersionNumber="1.0" RequestResponse="Request"> <Request..........blah

Message 2 -
<?xml version="1.0" encoding="UTF-8"?><Data VersionNumber="1.0" RequestResponse="Request"> <Request..........blah

When debugging Message 1 shows the VersionNumber and RequestResponse as elements in the Variables view

Message 2 shows them as @VersionNumber and @RequestResponse

If whilst I am debugging with Message 2 I alter the PAYLOAD variable and paste in the escaped namespace declarations prior to parsing then it behaves as Message 1.

Is there a reason for the difference?
Back to top
View user's profile Send private message MSN Messenger
smdavies99
PostPosted: Thu Mar 19, 2015 3:25 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

You should not be using the MRM Parser for XML Messages. This was replaced by XMLNS and then XMLNSC around V5 days.

The MRM Parser does not handle XML Attributes for starters.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
RichA
PostPosted: Thu Mar 19, 2015 3:45 am    Post subject: Reply with quote

Centurion

Joined: 14 Mar 2002
Posts: 102

That's fine, however this is some legacy code which I may or may not be allowed to change, at the moment let's assume that I cannot change it.

Can you see from the message whether the attributes should be interpreted differently? Am I going to have to force the application generating the message to put in these namespace declarations to cater for what may be a bug in the obsolete XML parser?

It is parsed into the MRM domain as a canonical message set for further processing down the line, and if it is true that the MRM parser does not handle XML attributes then why the difference in behaviour?
Back to top
View user's profile Send private message MSN Messenger
smdavies99
PostPosted: Thu Mar 19, 2015 4:45 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

From what I can remember the MRM XML Parser does not support Namespaces properly.

If this is a real problem then raise a PMR with IBM and get the definitive answer. You may have to switch to the XMLNS/XMLNSC PArser if there are namespaces involved.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
kimbert
PostPosted: Thu Mar 19, 2015 5:04 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
From what I can remember the MRM XML Parser does not support Namespaces properly.
MRM XML supports both namespaces and attributes. It does represent the namespace prefixes in a different way to XMLNS and XMLNSC though.
@smdavies99: You can be forgiven for not remembering the details after this long!

Quote:
So, it's reasonably complex, the message itself is made up of three layers, each layer being xml, the base payload of the message is double escaped, then there's a wrapper around that which is single escaped and that sits within the unescaped outer wrapper.
I recommend that you talk to the developers of the sending application and ask them to use CDATA sections.
Quote:
That's fine, however this is some legacy code which I may or may not be allowed to change, at the moment let's assume that I cannot change it.
Er...if you are not changing it, then how did the problem arise? Was this message flow *ever* working?
Quote:
Can you see from the message whether the attributes should be interpreted differently? Am I going to have to force the application generating the message to put in these namespace declarations to cater for what may be a bug in the obsolete XML parser?
It's hard to say. You have provided plenty of information, but we may need more. Remember that the MRM is a model-driven parser, so it has to match every item in the message tree against the message set in order to work out whether it is an element or an attribute. It's possible that your message tree structure does not match the message set structure.
You can diagnose this by taking a debug-level user trace. The MRM parser explains how the matching process is working via the user trace. Look for 'self-defined' or 'self-defining' in a trace message emitted by the MRM component.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
RichA
PostPosted: Thu Mar 19, 2015 5:20 am    Post subject: Reply with quote

Centurion

Joined: 14 Mar 2002
Posts: 102

Hi, right, now I think I've got it, I hadn't noticed the default namespace declaration and had previously thought they were all namespace prefix declarations. It's when I transcribed the message here that I noticed and it took me a little while to twig.

It's not the code which has changed, it's the message generation which changed.

Putting the Data element and the VersionNumber and RequestResponse attributes into the right namespace has fixed it.

It's not clear whether there's going to be the motivation to re-factor the existing code but I thank you for pointing out how necessary it is and it is something I will recommend.

Thanks.
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Namespaces and attributes
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.