Author |
Message
|
chenna.hari |
Posted: Tue Jun 08, 2010 10:32 am Post subject: Character reference "" is an invalid |
|
|
Centurion
Joined: 21 Mar 2009 Posts: 103
|
I have in input xml and need to parse this xml and iam getting the error
Character reference "" is an invalid XML character.
Can anyone help how to solve this error? |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 08, 2010 10:33 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Tell the sending system to send you valid XML data. |
|
Back to top |
|
 |
chenna.hari |
Posted: Tue Jun 08, 2010 10:37 am Post subject: |
|
|
Centurion
Joined: 21 Mar 2009 Posts: 103
|
But can you tell me the possbility to access the element containing this data |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Jun 08, 2010 10:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If a fruit vendor offers you a rotten fruit, do you look for ways to cut out the bad spots?
Or do you tell them to give you a piece of fresh fruit?
Current versions of Broker will replace illegal XML values with substitution characters, in at least some circumstances. This could essentially be causing your issue, where the sender has sent you bytes that are illegal in XML and these bad bytes have been turned into a substitution character, but the act of doing so has now rendered the document into an illegal XML document.
Except it was already an illegal XML document because it had illegal XML characters in it. |
|
Back to top |
|
 |
mqmatt |
Posted: Tue Jun 08, 2010 11:20 am Post subject: |
|
|
 Grand Master
Joined: 04 Aug 2004 Posts: 1213 Location: Hursley, UK
|
A O'D's got a good anecdote on this.  |
|
Back to top |
|
 |
chenna.hari |
Posted: Tue Jun 08, 2010 11:28 am Post subject: |
|
|
Centurion
Joined: 21 Mar 2009 Posts: 103
|
in message broker, still is there any way to transform this illegal xml document???? |
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 08, 2010 11:38 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Please post the actual snippet of XML that is causing the problem. I would like to know whether the string that you quoted is the real string from the input document, so please
a) enclose the snippet in [code] tags and
b) use the preview button before you click submit, and check that it looks exactly like the original document.
Quote: |
in message broker, still is there any way to transform this illegal xml document???? |
No XML parser, in any product, should accept that XML and process it. You can write some custom Java or ESQL to fix up the illegal XML. Nobody can help you with that, because only you can possibly know what kinds of illegal XML you are expecting to receive. The best solution is to ask the sender to send legal XML. |
|
Back to top |
|
 |
joebuckeye |
Posted: Tue Jun 08, 2010 11:58 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
Quote: |
in message broker, still is there any way to transform this illegal xml document???? |
Sure, you could treat it as a string and handle all the parsing yourself. But that way madness lies. |
|
Back to top |
|
 |
chenna.hari |
Posted: Tue Jun 08, 2010 12:17 pm Post subject: |
|
|
Centurion
Joined: 21 Mar 2009 Posts: 103
|
I cannot give the full xml document. but here the following sample.
Code: |
<element></element> |
|
|
Back to top |
|
 |
kimbert |
Posted: Tue Jun 08, 2010 1:08 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
OK - so here is the rule that is being broken : http://www.w3.org/TR/2006/REC-xml-20060816/#dt-charref
Note that a character reference must still resolve to a valid XML character, and the character 0x07 is not a valid XML character.
It is up to you how you fix it. Almost any *correct* fix-up algorithm will end up looking like an XML parser. If you think you can get away with something simpler, feel free to try. Just parse the message as a BLOB, convert to a string, fix it up, and re-parse. |
|
Back to top |
|
 |
joebuckeye |
Posted: Wed Jun 09, 2010 4:41 am Post subject: |
|
|
 Partisan
Joined: 24 Aug 2007 Posts: 365 Location: Columbus, OH
|
The problem with fixing the document though is that the sender may consider the 0x07 valid data for that field. They have to be aware that you are changing their data before sending it on.
We've seen these sorts of invalid characters in dealing with mainframe groups creating XML's to send to the broker.
I would say your responsibility is to notify the sender that they are sending you an invalid XML and tell them what the bad character is and where you found it. Then they can fix it.
If you fix this for 0x07, what is to prevent them from sending 0x08 the next day? The sooner the sending group is made aware of what is valid in an XML document the easier your life will be in the long run. |
|
Back to top |
|
 |
|