Re: Attribute values with unresolved entities

Elliotte Rusty Harold <[email protected]> Sun, 25 Apr 2004 15:10:14 -0400
Newsgroups gmane.text.xml.sax.devel
Message-ID <p0601021abcb1bb66a8fb@[192.168.254.88]>
At 3:02 PM -0400 4/25/04, Karl Waclawek wrote:

>Expat currently expands the reference to nothing, just like Xerces.
>What else can one do? There is no streaming context for reporting attributes.
>
>>  I don't see a clean solution here. Suggestions are appreciated, but I
>>  think we do need to address this case in the JavaDocs. I think I'm
>>  leaning toward throwing an exception, but others may feel differently.
>
>If there is an exception it would mean there is an error.
>But is there?


Yes, though it may be an unfixable design error in SAX. The real 
question is this: should the parser silently throw away content with 
no notice to the user/client? That's what it's doing now. This really 
worries me. I think I might prefer it if the parser gave up and said, 
I can't process such documents, much like it gives up now on 
namespace malformed documents by default.

Or perhaps there could be a method in EntityResolver, ContentHandler, 
or somewhere that simply received notification of skipped entities 
and returned some replacement text? It might be useful beyond simply 
attribute values. Hmm, what if skippedEntity were not void? Not 
backwards compatible I suppose.  Hindsight's 20/20 and all that. But 
maybe we can think of something, or at the very least note the issue 
in the JavaDoc.

According to the XML spec, "It is an error if an attribute value 
contains a reference to an entity for which no declaration has been 
read." Thus I think the error() method in ErrorHandler should be 
called, and if Xerces is not doing that but merely silently throwing 
away the entity reference then yes, that is a bug, and it should be 
fixed.
-- 

   Elliotte Rusty Harold
   [email protected]
   Effective XML (Addison-Wesley, 2003)
   http://www.cafeconleche.org/books/effectivexml            
   http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA 


-------------------------------------------------------
This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek
For a limited time only, get FREE Ground shipping on all orders of $35
or more. Hurry up and shop folks, this offer expires April 30th!
http://www.thinkgeek.com/freeshipping/?cpg=12297
_______________________________________________
List: sax-devel, [email protected]
See:  http://www.saxproject.org/
https://lists.sourceforge.net/lists/listinfo/sax-devel