DTD.validate(xmlroot) has no reason in .error_log why validation fails

Bug #910014 reported by jenisys
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libxml2
Fix Released
Medium
lxml
Fix Released
Low
scoder

Bug Description

DTD.validate() returns false, but shows no reason in the DTD.error_log attribute.
This case occurs for example when an XML ID attribute value is used twice in an XML document.
"xmllint --valid ..." (that is based on libxml2, also used by lxml) shows these kind of errors.

NOTE:
Eclipse XML Editor also shows these kind of problems as error markers.

VERSION-INFO:
  Python : (2, 6, 6, 'final', 0)
  lxml.etree : (2, 3, 2, 0)
  libxml used : (2, 7, 3)
  libxml compiled : (2, 7, 3)
  libxslt used : (1, 1, 24)
  libxslt compiled : (1, 1, 24)

Revision history for this message
jenisys (jenisys) wrote :
Revision history for this message
jenisys (jenisys) wrote :
Revision history for this message
jenisys (jenisys) wrote :

XMLLINT OUTPUT:
xmllint --valid persons.with_duplicate_ID.xml
persons.with_duplicate_ID.xml:7: element person: validity error : ID pid.1 already defined
    <person id="pid.1" description="OOPS, same ID as Alice">
                                                           ^

scoder (scoder)
Changed in lxml:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
scoder (scoder) wrote :

Looks like a bug in libxml2 to me. It has this code in valid.c:

   2636 if ((ctxt != NULL) && (ctxt->error != NULL)) {
   2637 xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
   2638 "ID %s already defined\n",
   2639 value, NULL, NULL);
   2640 }

lxml does not currently set ctxt->error, because all errors are collected globally. The check above prevents libxml2 from reporting the error at all in that case, although it would work if the check wasn't there. Meaning, it's really just exactly this error message that does not go through. Thanks for stumbling over it. :)

Changed in libxml2:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → scoder (scoder)
status: Confirmed → Fix Committed
milestone: none → 3.3
Revision history for this message
scoder (scoder) wrote :

Fixed in lxml 3.3.2.

Changed in lxml:
status: Fix Committed → Fix Released
Changed in libxml2:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.