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 » XMLNSC parser may have a bug

Post new topic  Reply to topic
 XMLNSC parser may have a bug « View previous topic :: View next topic » 
Author Message
parliament
PostPosted: Tue May 30, 2017 6:43 am    Post subject: XMLNSC parser may have a bug Reply with quote

Novice

Joined: 30 May 2017
Posts: 11

Hi,

I have the folowing flow:

MOinput-->JavaComputeNode-->MQoutput

The input node has XMLNSC parser set. If I were to send a XML message which has a target namespace set, for some reason, in the javaComputeNode, I get one more namespace declaration(the same namespace) like below. Furthermore, the XSD has elementFormDefault="unqualified", and some elements must be placed outside the target namespace with xmlns="". The broker just ignores those statements, rendering all elements with the target namespace. The later aspect of the problem is available for all parsers be it BLOB, XMLNS or XMLNSC.


message entering flow:
<Root xmlns:"someTargetNamespace">
<someElement xmlns="">
........
</someElement>
</Root>

becomes this when in JCN:
<Root xmlns="someTargetNamespace" xmlns:xmlns="someTargetNamespace">
<someElement>
........
</someElement>
</Root>

As one would guess, this blows up if I were to use any type of message manipulation that cares for the schema while inside the JCN.

Has anyone ever encountered this?
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue May 30, 2017 7:46 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

https://www.ibm.com/support/knowledgecenter/SSMKHH_9.0.0/com.ibm.etools.mft.plugin.doc/index.html

Notice the methods that work with the namespace of an element.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
timber
PostPosted: Wed May 31, 2017 12:56 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
If I were to send a XML message which has a target namespace set, for some reason, in the javaComputeNode, I get one more namespace declaration(the same namespace) like below.
You need to explain what your Java code has done to the message tree, and why.

As mqjeff rightly points out, you do need to understand how namespaces are represented in the message tree.
Back to top
View user's profile Send private message
parliament
PostPosted: Wed May 31, 2017 1:51 am    Post subject: Reply with quote

Novice

Joined: 30 May 2017
Posts: 11

Hi,

Thank you for the replyes. To further detail the problem, I extract the MbElement that represents my message. Next I convert it to a DOMNode which is transformed to string like so:

TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer;
try {
transformer = tf.newTransformer();
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
StringWriter writer = new StringWriter();
transformer.transform(new DOMSource(myMbElement.getDOMDocument()), new StreamResult(writer));
String output = writer.getBuffer().toString();
} catch( Exception e){
//Dostuff
}

I ran a test to convert the same XML, but this time read from a file, and it does not alter the structure at all.

It seems that based on the IIB parser, getDOMDocument() returns different results.[/list]
_________________
waiter: Have a nice meal
me: You too!
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed May 31, 2017 1:58 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

parliament wrote:
Hi,

Thank you for the replyes. To further detail the problem, I extract the MbElement that represents my message. Next I convert it to a DOMNode which is transformed to string like so:

Code:
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer;
        try {
            transformer = tf.newTransformer();
            transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
            StringWriter writer = new StringWriter();
            transformer.transform(new DOMSource(myMbElement.getDOMDocument()), new StreamResult(writer));
            String output = writer.getBuffer().toString();
         } catch( Exception e){
           //Dostuff
         }


I ran a test to convert the same XML, but this time read from a file, and it does not alter the structure at all.

It seems that based on the IIB parser, getDOMDocument() returns different results.


And why do you use a DOMDocument to serialize the message tree?
IIB has ways to do that, that are way more efficient... Use those...
What is the result of MbElement.toBitStream()???
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
parliament
PostPosted: Wed May 31, 2017 2:10 am    Post subject: Reply with quote

Novice

Joined: 30 May 2017
Posts: 11

fjb_saper wrote:


And why do you use a DOMDocument to serialize the message tree?
IIB has ways to do that, that are way more efficient... Use those...
What is the result of MbElement.toBitStream()???



Haha, just as I tried this, I saw your message. Indeed, using MbElement.toBitStream() does a much better job, without all the DOM-->transformer mambo jambo.

So this does the trick. But it is still interesting how MbElement.getDOMNode() returns different results for the same input, although it has different parsers. Do you have any idea why this is so?

All in all, thank you for your help!
_________________
waiter: Have a nice meal
me: You too!
Back to top
View user's profile Send private message
timber
PostPosted: Wed May 31, 2017 3:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

The message tree is not a DOM, but it can pretend to be one. The DOM interface is just a wrapper that reads/writes the underlying message tree using native IIB APIs.

My best guess is that there is a small buglet in that wrapper, but don't just assume that. It seems like a pretty simple scenario and I would be surprised if there was an obvious defect like this in such a well-tested piece of code.

I think you know this already, but it's best to use the native XML parser in IIB for parsing and serializing XML. Use of the Java DOM interface is recommended for experts only, and for specific purposes.
Back to top
View user's profile Send private message
parliament
PostPosted: Wed May 31, 2017 5:05 am    Post subject: Reply with quote

Novice

Joined: 30 May 2017
Posts: 11

Thank you guys for your help!

Cheers
_________________
waiter: Have a nice meal
me: You too!
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 » XMLNSC parser may have a bug
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.