GNOME Bugzilla – Bug 167754
Schema: xsd:all combined with xsd:element ref="..." is rejected
Last modified: 2009-08-15 18:40:50 UTC
Please describe the problem: Hello, For the following schema: <?xml version="1.0" encoding="UTF-8" ?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:target="http://www.example.com/Test" targetNamespace="http://www.example.com/Test" version="1.0" elementFormDefault="qualified" > <xsd:element name="foo" /> <xsd:element name="bar" /> <xsd:element name="joe" /> <xsd:complexType name="dominik"> <xsd:all> <xsd:element minOccurs="0" ref="target:foo" /> <xsd:element minOccurs="0" ref="target:bar" /> <xsd:element minOccurs="0" ref="target:joe" /> </xsd:all> </xsd:complexType> <xsd:element name="test"> <xsd:complexType> <xsd:sequence> <xsd:element maxOccurs="unbounded" name="child" type="target:dominik" /> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> and the document: <test xmlns="http://www.example.com/Test"> <child> <foo/> </child> <child> <foo/> <joe/> </child> </test> is the message: bash-2.05b$ xmllint --noout --schema test.xsd test.xml test.xml:2: element child: Schemas validity error : Element 'child' [complex type 'dominik']: Missing child element(s). Expected is ( #eRef 2 ). test.xml:7: element joe: Schemas validity error : Element 'joe': This element is not expected. test.xml fails to validate This is with libxml2 2.6.17. The document validates fine with Microsoft's: http://apps.gotdotnet.com/xmltools/xsdvalidator/Default.aspx If the above example is changed into: <xsd:all> <xsd:element minOccurs="0" name="foo" /> <xsd:element minOccurs="0" name="bar" /> <xsd:element minOccurs="0" name="joe" /> </xsd:all> it works in libxml2. To me, it looks like libxml2 reject a valid Schema. Cheers, Frans Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Fixed in CVS (xmlschemas.c rev. 1.110). The content model automaton was built with the element declaration, and - incorrectly - with the reference to it. Seems to have been a side affect of a previous bug fix. I added your test case to the regression tests. Thanks for the report Frans!
This should be closed by release of libxml2-2.6.21, thanks, Daniel