Search code examples
xmlxsdxmllint

xmllint validation succeeds on invalid input


Why does xmllint not report validation failure for the following xsd and xml ?

t.xsd

<?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="letter">
   <xs:simpleType>
      <xs:restriction base="xs:string">
      <xs:pattern value="([a-z])+"/>
      </xs:restriction>
   </xs:simpleType>
</xs:element>
</xs:schema>

t.xml

 <letter></letter>

$ ./xmllint --schema t.xsd t.xml

<?xml version="1.0"?>
<letter/>
t1.xml validates

Solution

  • The input does not look valid to me (Mark O'Connor says it's valid, but I don't see any argument to that effect, just a bald statement). Equally to the point, it doesn't look valid to Xerces J or to Saxon EE.

    The XSD support in xmllint is known to be a bit spotty, but mostly that means that there are parts of the spec that aren't supported; this looks more like a straightforward bug in the regex routine. I see several unresolved regex bugs in the gnome bugtracker for libxml; perhaps this is related. I've opened a new bug report with this issue.