[xml] validation problem with external entities



hallo,

i was just pointed at a problem with validating parsers if parts of the 
document are included with external entities.

i traced the problem to be a problem with the parser context: 
although the generic error handler throws an error message, the parser 
context lies about the valid state of the document
(ctxt->valid == 1 instead of 0). :

On Tue, May 07, 2002 at 10:39:26AM -0400, Erik Ray wrote:
I'm parsing a DocBook document (with version 4.0 of the DTD) with the
<book> element in one file and <chapter> elements in separate files as
external entities.

I tried an experiment to see if the parser correctly validates
documents. When I misspelled the element <chapter> as <chapterx> the
parser correctly told me that this was invalid. However, when I
corrected that and mispelled the <title> element just inside the
<chapter> element like this:

  <chapter><titlex>foo</titlex>

...the parser did not complain. It seems as if the validation doesn't
go below a certain level. 

this problem only appears with a validating parser
(xmlDoValidityCheckingDefaultVal = 1 and xmlLoadExtDtdDefaultValue = 1).

currently i additionaly check if my error variable is set, but i think 
the parser context should contain the correct information in the valid member,
so one must no catch the error message seperately. 

i attach two files that show where the problem occours.

(btw. i found this problem with all more recent versions of libxml2 ( > 2.4.14))

christian

Attachment: book.xml
Description: Text document

Attachment: ch01.xml
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]