GNOME Bugzilla – Bug 582906
xmlschemas.c error validating multiple imports of the same schema with no targetNamespace
Last modified: 2009-08-07 18:34:14 UTC
Please describe the problem: When validating a schema that includes the same file that has no targetNamespace defined an internal error is thrown. http://mail.gnome.org/archives/xml/2009-March/msg00014.html Steps to reproduce: 1. Get the test-cases.tar.bz2 from this issue. 2. Unpack the archive and change to the case-1 directory 3. Run 'xmllint --schema aggregator.xsd validate_me.xml Actual results: You get a internal error: xmlSchemaParseIncludeOrRedefine: trying to use an already parsed schema for a different targetNamespace Expected results: The schema should validate successfully. Does this happen every time? Yes Other information: From the XML Schema Part 1: Structures "The ·XML Schema· corresponding to <schema> contains not only the components corresponding to its definition and declaration [children], but also all the components of all the ·XML Schemas· corresponding to any <include>d schema documents. Such included schema documents must either (a) have the same targetNamespace as the <include>ing schema document, or (b) no targetNamespace at all, in which case the <include>d schema document is converted to the <include>ing schema document's targetNamespace." libxml2 should not throw this error, it should just reassign the targetNamespace of the including document to the one being parsed.
Created attachment 134786 [details] Testcases mentioned in the bug report The test cases for this error
Created attachment 134787 [details] [review] Proposed patch Here is a proposed patch that is better than the one submitted to the mailing list. It checks to see if bucket->origTargetNamespace is NULL. If it is not then it prints an error message and exits gracefully. The case-2 in the test-cases.tar.bz2 was an attempt to trigger this code, but the error gets caught earlier in the document parsing if a targetNamespace is assigned that is different from the importing document.
Okay ... yes I was surprized by the original suggestion on the list to just remove the check in all cases, that looks just fine to me, thanks a lot. Applied and commited, I also included both test cases in the regression suite, thanks again ! Daniel