[jdom-interest] ASCII Non Printable Characters

Adrian Nolan adrnola at hotmail.com
Fri Oct 19 08:08:08 PDT 2001


Hi All - Maybe you have come across this before,

We have XML messages and one of the elements is a "Body" tag. Other apps use 
the XML helper tool I created to populate the various elements (No 
validation, but the message is well formed). Anyways the body is getting 
filled with ASCII chars, so I presume the XML encoding standard UTF-8 should 
be more than capable of handling all these chars (and it has no problem 
doing so).

However when the message is passed to the JDOM SAXBulder builder it 
encounters non-printing characters e.g. escape char (Decimal 027) in the 
message (which is fine its the way the original message is constructed and 
we have no control over it) however the parser is not able to handle escape 
chars and it is throwing an exception.

Exception I get :

094248.XIE185AP!JavaServer.322: main: Error on line 2: An invalid XML 
character (Unicode: 0x1b) was found in the element content of the document.
094248.XIE185AP!JavaServer.322: main: org.jdom.JDOMException: Error on line 
2: An invalid XML character (Unicode: 0x1b) was found in the element content 
of the document.
094248.XIE185AP!JavaServer.322: main: 	at 
org.jdom.input.SAXBuilder.build(SAXBuilder.java, Compiled Code)


Basically my question is:
Should the parser just ignore these non-printable characters ??
Or is there some way of doing this when setting up the parser?
Does the XMLFilter filter chars that can some how be transposed during 
Output again ?

-------------------------------------------------------
OK - Since I did up the question above I have come across the answer. 
Basically chars 0 through 31 and 127 can't be used in any part of an XML 
Document, except carriage return and line feed.

Will using XML SCHEMA solve this problem ?

Does Xerces support XML Schema ?

Is there any seamless way to do handle these non-printable characters ?


If you have made it this far ......... thanks for reading.

Thanks in advance for any infos or pointers.

Regards,
Adrian.

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp




More information about the jdom-interest mailing list