Problem with XML Schema validation

Hi all There seems to be 2 ways of validating an xml document with XML Schema. One way is to create a XMLParser object and pass it an XMLSchema object as an argument. If you use this parser object with etree.parse() or etree.fromstring(), it validates the document against the schema. The other way is to parse the document first, and then validate it using XMLSchema.validate() or XMLSchema.assertValid(). I have always used the first method – I was unaware of the second one. However, I have just found a particular error that is detected by the second method, but not by the first one. The error is the use of duplicate “id” attributes, if it is specified in the schema as being of type “xs:ID”. I have a document with duplicate ids. Validating with the first method passes. Validating the same document, with the same schema, using the second method, gives the following - lxml.etree.DocumentInvalid: Element '{http://www.omg.org/spec/BPMN/20100524/MODEL}dataOutput', attribute 'id': 'user_row_id' is not a valid value of the atomic type 'xs:ID'., line 38 Is this a bug? Should I always use the second method? I am using lxml version 3.6.4. Thanks Frank Millman
participants (1)
-
Frank Millman