Author |
Message
|
paustin_ours |
Posted: Thu Jun 13, 2013 12:57 am Post subject: Opaque parsing |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
i have a incoming xml that i believe has some non unicode data in the cdata section that causes xml parser errors while parsing
i thought of using opque parsing for that tag that has the cdata
i set the opaque element to be
//customerData
I am still getting the error
An XML parsing error ''An invalid XML character (Unicode: 0x0) was found in the CDATA section.'' occurred on line 1 column 327 when parsing element ''/Root/XMLNSC/customer/customerData''.
not sure what i am missing. Please help. Thanks.[/u] |
|
Back to top |
|
 |
Esa |
Posted: Thu Jun 13, 2013 1:03 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Even an opaque element is parsed. The parser just dont build a message tree for it. Setting the element to opaque doesn't help if the element contains invalid XML. |
|
Back to top |
|
 |
cociu_2012 |
Posted: Thu Jun 13, 2013 1:07 am Post subject: Re: Opaque parsing |
|
|
Acolyte
Joined: 06 Jan 2012 Posts: 72
|
paustin_ours wrote: |
i have a incoming xml that i believe has some non unicode data in the cdata section that causes xml parser errors while parsing
i thought of using opque parsing for that tag that has the cdata
i set the opaque element to be
//customerData
I am still getting the error
An XML parsing error ''An invalid XML character (Unicode: 0x0) was found in the CDATA section.'' occurred on line 1 column 327 when parsing element ''/Root/XMLNSC/customer/customerData''.
not sure what i am missing. Please help. Thanks.[/u] |
Are you sure you're not having one of these situations:
Quote: |
Do not parse an element opaquely in any of the following cases:
The message flow must access one of its child elements.
The message flow changes the namespace prefix in a way that affects the opaque element or one of its child elements and the element is to be copied to the output bit stream.
The element, or any child element, contains a reference to an internal entity that is defined in an inline DTD and the element is to be copied to the output bit stream.
The element contains child attributes that have default values that are defined in an inline DTD and the element is to be copied to the output bit stream. |
Also pot the debug trace. Don't use the visual one. |
|
Back to top |
|
 |
paustin_ours |
Posted: Thu Jun 13, 2013 1:36 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Esa wrote: |
Even an opaque element is parsed. The parser just dont build a message tree for it. Setting the element to opaque doesn't help if the element contains invalid XML. |
Is there a way to get around this problem? |
|
Back to top |
|
 |
cociu_2012 |
Posted: Thu Jun 13, 2013 2:01 am Post subject: |
|
|
Acolyte
Joined: 06 Jan 2012 Posts: 72
|
paustin_ours wrote: |
Is there a way to get around this problem? |
Don't parse. Get rid of the invalid elements (escape, remove, comment), then parse.
And notice that this is a workarround. Consumers/app's should no send invalid payloads at any time. |
|
Back to top |
|
 |
Esa |
Posted: Thu Jun 13, 2013 2:01 am Post subject: |
|
|
 Grand Master
Joined: 22 May 2008 Posts: 1387 Location: Finland
|
Yes. You can to preprocess the message as a BLOB and use for example regular expressions to remove the offending character. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jun 13, 2013 8:22 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
It is not a 'non-Unicode' character. It is simply a character that is not allowed within an XML document. The application that wrote that XML document is at fault.
Your choices are:
- fix the source application so that it sends correct XML
or
- parse in the BLOB domain and remove any nulls before parsing with XMLNSC. |
|
Back to top |
|
 |
rekarm01 |
Posted: Thu Jun 13, 2013 9:34 am Post subject: Re: Opaque parsing |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
paustin_ours wrote: |
An XML parsing error ''An invalid XML character (Unicode: 0x0) was found in the CDATA section.'' occurred on line 1 column 327 when parsing element ''/Root/XMLNSC/customer/customerData''. |
If the CDATA section is supposed to contain non-character data, then the application should apply some sort of binary-to-text encoding, such as Base64 or HexBinary, before putting it in an XML message. |
|
Back to top |
|
 |
|