Question

We have XSDs and sample XMLs that were created under .NET (and presumably passed validation), but they fail to be validated under xmllint. We're trying to determine if one side or the other is 'incorrect' or if this is something ambiguous in the spec. I've tried searching here and on google, but can't find anything that describes this same problem. Instead of posting the original XSDs & XML, I've created a smaller test that reproduces the problem.

The XSD is:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           elementFormDefault="qualified" 
           attributeFormDefault="unqualified">
  <xs:complexType name="A">
    <xs:sequence>
      <xs:element name="B" nillable="true" type="B" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="A" nillable="true" type="A" />
  <xs:complexType name="B">
    <xs:sequence>
      <xs:element name="date" 
                  minOccurs="1" 
                  maxOccurs="50" 
                  nillable="true" 
                  type="xs:date" />
    </xs:sequence>
  </xs:complexType>
  <xs:element name="B" nillable="true" type="B" />
</xs:schema>

The XML is:

<?xml version="1.0" encoding="UTF-8"?>
<A xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:noNamespaceSchemaLocation="test.xsd">
  <B xsi:nil="true"></B>
</A>

The xmllint command run is:

xmllint --schema test.xsd --noout test.xml

And the output of xmllint is:

test.xml:3: element B: Schemas validity error : Element 'B': Missing child element(s). Expected is ( date ).
test.xml fails to validate

I'm pretty much a beginner XSD/XML 'developer', so feel free to rip away. :)

Was it helpful?

Solution

The XML instance you show is schema-valid against the XSD schema you show. So says Xerces J, so says MSV, so says Saxon, and (for what it's worth) so say I.

The XSD support in xmllint is known to be incomplete; it looks like this is one of the incomplete areas.

(Nice job cutting the problem down to a small test case, by the way. Good work!)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top