|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
XMLNSC parser may have a bug |
« View previous topic :: View next topic » |
Author |
Message
|
parliament |
Posted: Tue May 30, 2017 6:43 am Post subject: XMLNSC parser may have a bug |
|
|
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 |
|
 |
mqjeff |
Posted: Tue May 30, 2017 7:46 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
timber |
Posted: Wed May 31, 2017 12:56 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
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 |
|
 |
parliament |
Posted: Wed May 31, 2017 1:51 am Post subject: |
|
|
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 |
|
 |
fjb_saper |
Posted: Wed May 31, 2017 1:58 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 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 |
|
 |
parliament |
Posted: Wed May 31, 2017 2:10 am Post subject: |
|
|
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 |
|
 |
timber |
Posted: Wed May 31, 2017 3:15 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
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 |
|
 |
parliament |
Posted: Wed May 31, 2017 5:05 am Post subject: |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|