Author |
Message
|
yshakraj |
Posted: Tue Feb 07, 2012 5:29 am Post subject: & to & conversion in message broker7 |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
Hi ,
I am having problem to convert the & symbol to & in message broker .
I have an xml file which have one tag ,having value "something &something " .when i tried to pass through an mqinput node ,with domain xmlnsc ,i am getting parse error.
if there any way to convert this,also to convert the special characters like "<" ,">" which may come in xml and create the same issue .
is there any way to do other than handling it in esql .
Thanks in advance ,
Vyshak |
|
Back to top |
|
 |
adubya |
Posted: Tue Feb 07, 2012 5:35 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
&,<,> are not legitimate content in XML so the parser rightly complains. Either escape such data correctly or use CDATA if you're looking to pass XML as content.
Basically, your input is invalid XML. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 07, 2012 6:00 am Post subject: Re: & to & conversion in message broker7 |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
yshakraj wrote: |
when i tried to pass through an mqinput node ,with domain xmlnsc ,i am getting parse error. |
That's because the document is not well formed and can't be parsed. Try opening it with IE or XMLSpy & see what happens.
yshakraj wrote: |
if there any way to convert this,also to convert the special characters like "<" ,">" which may come in xml and create the same issue . |
Yes because they're not allowed to appear in XML any more than "&" is. All such characters should have been escaped (& < etc) before it reaches you.
yshakraj wrote: |
is there any way to do other than handling it in esql . |
Yes. Get whoever's sending the file to send well-formed XML not just a string with lots of "<' and '>' in it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
yshakraj |
Posted: Tue Feb 07, 2012 6:05 am Post subject: |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
Thanks for the response, i agree with you that is not the valid xml values how ever how can i get escaped such things in mb ,do we have any option to do that , and how to solve this with cdata . |
|
Back to top |
|
 |
yshakraj |
Posted: Tue Feb 07, 2012 6:28 am Post subject: |
|
|
 Voyager
Joined: 14 Sep 2011 Posts: 91
|
thanks vitor , so the way out is to get the wellformed xml,i will check with them . thanks all . |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 07, 2012 6:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
yshakraj wrote: |
how to solve this with cdata . |
You can't solve this with CDATA. Those values cannot appear unescaped in an XML document, even in a CDATA section.
Your only option (I hestiate to call it an option) is to have them base64encode the file and decode it your end. It would be much, much easier for everyone including them to just fix the XML so it's well formed. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
adubya |
Posted: Tue Feb 07, 2012 6:54 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Feb 07, 2012 6:58 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
adubya wrote: |
Vitor wrote: |
You can't solve this with CDATA. Those values cannot appear unescaped in an XML document, even in a CDATA section.. |
I didn't think this was the case.
http://www.w3.org/TR/REC-xml/#sec-cdata-sect |
Regardless, the sending app still needs to be modified to set the CDATA section around the bad characters. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Feb 07, 2012 7:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
adubya wrote: |
Vitor wrote: |
You can't solve this with CDATA. Those values cannot appear unescaped in an XML document, even in a CDATA section.. |
I didn't think this was the case.
http://www.w3.org/TR/REC-xml/#sec-cdata-sect |
There's some problem with markup in a CDATA section  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
adubya |
Posted: Tue Feb 07, 2012 7:04 am Post subject: |
|
|
Partisan
Joined: 25 Aug 2011 Posts: 377 Location: GU12, UK
|
Vitor wrote: |
adubya wrote: |
Vitor wrote: |
You can't solve this with CDATA. Those values cannot appear unescaped in an XML document, even in a CDATA section.. |
I didn't think this was the case.
http://www.w3.org/TR/REC-xml/#sec-cdata-sect |
There's some problem with markup in a CDATA section  |
Yes, use of the end of CDATA tag ]]> and the CDATA element name itself as CDATA sections can't be nested. |
|
Back to top |
|
 |
kimbert |
Posted: Tue Feb 07, 2012 7:29 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
There's some problem with markup in a CDATA section |
Yes, there can be. But the more usual problem is that people expect CDATA to make *everything* safe - and then they use it to wrap up badly-formed XML ( such as in an error report ). The problem is that CDATA doesn't allow illegal characters like NUL and other low-valued characters. But that's a very common type of badly-formedness ( I made up a new noun there ). |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Feb 07, 2012 8:33 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
kimbert wrote: |
Quote: |
There's some problem with markup in a CDATA section |
Yes, there can be. But the more usual problem is that people expect CDATA to make *everything* safe - and then they use it to wrap up badly-formed XML ( such as in an error report ). The problem is that CDATA doesn't allow illegal characters like NUL and other low-valued characters. But that's a very common type of badly-formedness ( I made up a new noun there ). |
Shouldn't that be 'malformed'?
IMHO, the only way to guarantee that you can report 'malformed' XML in an XML structure is for the bad stuff to be encoded into a BLOB using the...
Wait for it
Wait for it....
ASBITSTREAM function.
Not exactly user friendly but you have preserved the data so that the original error is not masked/hidden. _________________ 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 |
|
 |
|