[xml] wrong line number with XML_PARSE_DTDVALID



Hi,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root[
<!ELEMENT root (a*)>
<!ELEMENT a EMPTY>
<!ATTLIST a xml:id ID #REQUIRED >
<!ATTLIST a parent IDREF #IMPLIED >
]>
<root>
        <a xml:id="ID0" parent="ID3"/>
        <a xml:id="ID1"/>
</root>

This document is well-formed, but the attribute parent (line 9) is not an existing ID.

xmlReadFile followed by xmlValidateDocument
--> line 9, IDREF attribute parent references an unknown ID "ID3"
OK.

xmlReadFile with options XML_PARSE_DTDVALID
--> line 11, IDREF attribute parent references an unknown ID "ID3"
Wrong, line 11 is the end of the document.

The error occurs at the end of the parsing in xmlValidateDocumentFinal (valid.c).
xmlValidateDocumentFinal raise an error thru  xmlErrValidNode.
In the first case ctxt->finishDtd is 0 and in the second case
ctxt->finishDtd is  XML_CTXT_FINISH_DTD_0 (or XML_CTXT_FINISH_DTD_1).
Thus, while parsing, libxml reports any error in xmlValidateDocumentFinal as occurring at the end of the document.
I suspect that the flag ctxt->finishDtd  is not correct at this step.

I suggest  to add:
ctxt->finishDtd=0;
in xmlValidateDocumentFinal.
This fixes my case, but perhaps may yield unexpected boundary effects ( variable ctxt->finishDtd is rather cryptic).

F.Delyon



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