Author |
Message
|
Frnd |
Posted: Mon Sep 05, 2011 1:02 am Post subject: & getting converted to & in message broker |
|
|
Apprentice
Joined: 04 Jun 2007 Posts: 33
|
Hi All,
Request your inputs on the below issue.
While parsing a message flow that contains an element value 'Johnson & Johnson, message broker is converting it to 'Johnson & Johnson'.The input message parser is XMLNSC with Validation type - Content and Value. The input node also refers to a message set where this element is defines as a string.The special character gets converted right after the input node itself.Is there any setting that can be done to ensure Message broker does not convert this special character to & which is an invalid XML content.. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 05, 2011 2:49 am Post subject: Re: & getting converted to & in message broker |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Frnd wrote: |
Hi All,
Request your inputs on the below issue.
While parsing a message flow that contains an element value 'Johnson & Johnson, message broker is converting it to 'Johnson & Johnson'.The input message parser is XMLNSC with Validation type - Content and Value. The input node also refers to a message set where this element is defines as a string.The special character gets converted right after the input node itself.Is there any setting that can be done to ensure Message broker does not convert this special character to & which is an invalid XML content.. |
Parsing 101. Special XML characters are converted back to normal when reading the value of the tag.
Working as expected.
They will get serialized back to a special character during the serializing process.
What happens when you assign "Johnson & Johnson" to an XML document node value and write (serialize) said document?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Frnd |
Posted: Mon Sep 05, 2011 8:48 pm Post subject: |
|
|
Apprentice
Joined: 04 Jun 2007 Posts: 33
|
Quote: |
What happens when you assign "Johnson & Johnson" to an XML ?
|
Hi fjb_saper,
thanks for the response..when i assign "Johnson & Johnson" to an XML, it failed..guess it was working as expected..
Thank you |
|
Back to top |
|
 |
Vitor |
Posted: Tue Sep 06, 2011 4:46 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Frnd wrote: |
it failed..guess it was working as expected..
|
For the record and largely for the benefit of future readers: this is not a broker behaviour. The string "Johnston & Johnston" is not allowed in any XML document but must be "Johnston & Johnston". Competent XML parsers know that's not what the data is supposed to look like and change the & back to an & when parsing in, and back to & when writing out.
One of the things you're paying good money to an XML parser for is so you don't need to worry about such things. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Sep 06, 2011 1:43 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Frnd wrote: |
Quote: |
What happens when you assign "Johnson & Johnson" to an XML ?
|
Hi fjb_saper,
thanks for the response..when i assign "Johnson & Johnson" to an XML, it failed..guess it was working as expected..
Thank you |
I did not say to assign to the XML but to the XML Document node value !
These are 2 different things, entirely!
The supposition here is that you know how to work the XML DOM model...
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
adubya |
Posted: Tue Sep 06, 2011 11:27 pm Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
fjb_saper wrote: |
Frnd wrote: |
Quote: |
What happens when you assign "Johnson & Johnson" to an XML ?
|
Hi fjb_saper,
thanks for the response..when i assign "Johnson & Johnson" to an XML, it failed..guess it was working as expected..
Thank you |
I did not say to assign to the XML but to the XML Document node value !
These are 2 different things, entirely!
The supposition here is that you know how to work the XML DOM model...
 |
Yes, I was surprised when the OP said your suggestion didn't work. |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Sep 07, 2011 12:08 am Post subject: Re: & getting converted to & in message broker |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Frnd wrote: |
when i assign "Johnson & Johnson" to an XML, it failed. |
Please explain more clearly what the message flow is doing, and how it fails.
The XML standard requires escaping certain characters (like '&') with predefined entities (like '&') in an unparsed XML message (that is before the input node, and after the output node). Within the message flow however, when copying the elements of the input XML message into the parsed message tree, the XML parser replaces '&' with '&', and when copying the contents of the parsed message tree to an output XML message, the XML parser replaces '&' with '&'. |
|
Back to top |
|
 |
rglack10 |
Posted: Thu Sep 08, 2011 6:04 am Post subject: |
|
|
Apprentice
Joined: 06 Jul 2011 Posts: 34
|
a bit of a random reply but you can use CDATA section in well-formed XML to handle non-standard characters if you so wish however you may have issues in a message flow extracting incorrectly formatted XML for example or something like control characters in mixed text etc..
I don't want to start a thread war with the crusaders out there.. I am mainly replying due to boredom..  |
|
Back to top |
|
 |
|