You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by ty...@emc.com on 2008/01/25 23:24:24 UTC
Problem parsing attribute with character 7F
Hi,
I am using Xerces 2.9.1. I am seeing something that I am not sure is a
bug or not. I have a document with an attribute with a 0x7F character
in it. When I parse it I am getting an exception. However, if I strip
the <?xml version="1.1" ?> off the document it parses ok. Here is the
document that fails parsing:
<?xml version="1.1" ?><dir name="177()dir" />
Here is the message from the org.xml.sax.SAXParseException:
An invalid XML character (Unicode: 0x7f) was found in the value of
attribute "name" and element is "dir".
My understanding is that 00-7F are all valid single byte characters in
UTF-8. Any assistance would be appreciated.
Thanks,
Ed
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
RE: Problem parsing attribute with character 7F
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
If you're generating an XML 1.1 document you don't have much choice. If you
want to include 0x7F you need to use a character reference.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
tyrrill_ed@emc.com wrote on 01/25/2008 06:55:05 PM:
> Hi,
>
> After thinking the choices you presented I tested encoding the
> character as , and that works. Is this the correct thing to do?
>
> Ed
>
> From: keshlam@us.ibm.com [mailto:keshlam@us.ibm.com]
> Sent: Friday, January 25, 2008 2:53 PM
> To: j-users@xerces.apache.org
> Subject: Re: Problem parsing attribute with character 7F
> 7F is a legal XML 1.0 character and XML 1.0 should accept it. And,
> yes, I believe that in UTF8 (are you SURE you're reading the file as
> UTF8 rather than some other encoding?) it should be a legitimate single
byte.
>
> However, the XML 1.0 spec's section 2.2 says "Document authors are
> encouraged to avoid "compatibility characters", as defined in section 6.8
of
> [Unicode] (see also D21 in section 3.6 of [Unicode3])." So using
> this character is ill-advised, even though it is legal.
>
> XML 1.1 does generally accept more characters than XML 1.0 does --
> but note that 7F is one of the RestrictedChars, and that XML 1.1
> explicitly says these may not appear within documents or external
> parsed entities. (Alas, the Recommendation does not explain why
> these are restricted.)
>
> Looks to me like you have several choices: Eliminate that character,
> encode it somehow (note that a numeric character reference probably
> wouldn't solve this problem), or go back to XML 1.0.
>
> ______________________________________
> "... Three things see no end: A loop with exit code done wrong,
> A semaphore untested, And the change that comes along. ..."
> -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish (http://www.ovff.
> org/pegasus/songs/threes-rev-11.html)
---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org
RE: Problem parsing attribute with character 7F
Posted by ty...@emc.com.
Hi,
After thinking the choices you presented I tested encoding the character
as , and that works. Is this the correct thing to do?
Ed
________________________________
From: keshlam@us.ibm.com [mailto:keshlam@us.ibm.com]
Sent: Friday, January 25, 2008 2:53 PM
To: j-users@xerces.apache.org
Subject: Re: Problem parsing attribute with character 7F
7F is a legal XML 1.0 character and XML 1.0 should accept it. And, yes,
I believe that in UTF8 (are you SURE you're reading the file as UTF8
rather than some other encoding?) it should be a legitimate single byte.
However, the XML 1.0 spec's section 2.2 says "Document authors are
encouraged to avoid "compatibility characters", as defined in section
6.8 of [Unicode] <http://www.w3.org/TR/REC-xml/#Unicode> (see also D21
in section 3.6 of [Unicode3] <http://www.w3.org/TR/REC-xml/#Unicode3>
)." So using this character is ill-advised, even though it is legal.
XML 1.1 does generally accept more characters than XML 1.0 does -- but
note that 7F is one of the RestrictedChars, and that XML 1.1 explicitly
says these may not appear within documents or external parsed entities.
(Alas, the Recommendation does not explain why these are restricted.)
Looks to me like you have several choices: Eliminate that character,
encode it somehow (note that a numeric character reference probably
wouldn't solve this problem), or go back to XML 1.0.
______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)
Re: Problem parsing attribute with character 7F
Posted by ke...@us.ibm.com.
7F is a legal XML 1.0 character and XML 1.0 should accept it. And, yes, I
believe that in UTF8 (are you SURE you're reading the file as UTF8 rather
than some other encoding?) it should be a legitimate single byte.
However, the XML 1.0 spec's section 2.2 says "Document authors are
encouraged to avoid "compatibility characters", as defined in section 6.8
of [Unicode] (see also D21 in section 3.6 of [Unicode3])." So using this
character is ill-advised, even though it is legal.
XML 1.1 does generally accept more characters than XML 1.0 does -- but note
that 7F is one of the RestrictedChars, and that XML 1.1 explicitly says
these may not appear within documents or external parsed entities. (Alas,
the Recommendation does not explain why these are restricted.)
Looks to me like you have several choices: Eliminate that character, encode
it somehow (note that a numeric character reference probably wouldn't solve
this problem), or go back to XML 1.0.
______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)