You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Reuben Sivan <rs...@savantis.com> on 2004/10/29 17:05:52 UTC

writing illegal characters

I recently got a parsing error reading an XML file which I had produced
programmatically.
The error is org.xml.sax.SAXParseException: Illegal XML character &#xb;.

The reason for the error, I found out, was that 0xb is an illegal XML
character.

I easily worked my way around the error, by filtering my data before
writing it to XML (which is consistent with my application).

In any case, my question is, given that 0xb and other control characters
are illegal in XML, shouldn't the function
Document.createTextNode(String) check its input and generate an
exception?

Thanks,

	Reuben



---------------------------------------------------------------------
To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: writing illegal characters

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
"Reuben Sivan" <rs...@savantis.com> wrote on 10/29/2004 11:05:52 AM:

> 
> I recently got a parsing error reading an XML file which I had produced
> programmatically.
> The error is org.xml.sax.SAXParseException: Illegal XML character &#xb;.
> 
> The reason for the error, I found out, was that 0xb is an illegal XML
> character.
> 
> I easily worked my way around the error, by filtering my data before
> writing it to XML (which is consistent with my application).
> 
> In any case, my question is, given that 0xb and other control characters
> are illegal in XML, 

They're not legal characters in XML 1.0 but they are in XML 1.1.

> shouldn't the function
> Document.createTextNode(String) check its input and generate an
> exception?

This was a conscious decision by the DOM WG [1], probably made for 
performance reasons. DOM Level 3 provides a method for checking 
well-formedness. See Document.normalizeDocument() [2].

> Thanks,
> 
>    Reuben
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
> 

[1] http://www.w3.org/DOM/faq.html#WFXML
[2] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Document3-normalizeDocument

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org