Re: Attribute values with unresolved entities
"Karl Waclawek" <[email protected]> Sun, 25 Apr 2004 18:08:39 -0400
| Newsgroups | gmane.text.xml.sax.devel |
|---|---|
| Message-ID | <005e01c42b11$dd64ddb0$0200a8c0@karlglen188> |
----- Original Message ----- From: "Elliotte Rusty Harold" <[email protected]> To: "Karl Waclawek" <[email protected]> Cc: <[email protected]> Sent: Sunday, April 25, 2004 3:10 PM > 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. The reason I am not convinced this is always a fatal error is below. > 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. In certain situations this seems to be in direct contradiction to the WFC: Entity Declared, which says this: <quote> ... Note that non-validating processors are not obligated to to read and process entity declarations occurring in parameter entities or in the external subset; for such documents, the rule that an entity must be declared is a well-formedness constraint only if standalone='yes'. </quote> In section 5.2 it also says: <quote> The information passed from the processor to the application may vary, depending on whether the processor reads parameter and external entities. For example, a non-validating processor may fail to normalize attribute values, include the replacement text of internal entities, or supply default attribute values, where doing so depends on having read declarations in external or parameter entities. </quote> This looks as if it is OK for a non-validating processor *not* to include replacement text of internal entities if the declaration has not been read. In addition, this is how "error" is defined - and it would allow the parsing to continue: <quote> error [Definition: A violation of the rules of this specification; results are undefined. Unless otherwise specified, failure to observe a prescription of this specification indicated by one of the keywords MUST, REQUIRED, MUST NOT, SHALL and SHALL NOT is an error. Conforming software MAY detect and report an error and MAY recover from it.] </quote> As opposed to <quote> fatal error [Definition: An error which a conforming XML processor MUST detect and report to the application. After encountering a fatal error, the processor MAY continue processing the data to search for further errors and MAY report such errors to the application. In order to support correction of errors, the processor MAY make unprocessed data from the document (with intermingled character data and markup) available to the application. Once a fatal error is detected, however, the processor MUST NOT continue normal processing (i.e., it MUST NOT continue to pass character data and information about the document's logical structure to the application in the normal way).] </quote> Karl ------------------------------------------------------- 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