libxml2 not ignoring whitespace when validating xsd:int
https://bugzilla.gnome.org/show_bug.cgi?id=726766) first reported by Markus Schöpflin (2014-03-20 08:42:48 UTC ). The problem is still present today. I tested and confirmed it using the xmllint tool as provided by libxml2-2.9.12 (as packaged for Fedora 33 and 34)
This is a copy of the old bugzilla issue #726766 (seecopy of old bugzilla text:
Versions tested and affected: 2.9.1-2 (FC), 2.7.6-14 (CentOS)
Given the following schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="a" type="xsd:int"/>
</xsd:schema>
And the following document:
<a> 42</a>
Xmllint fails to validate this:
$ xmllint --schema test_schema.xml test_doc.xml
<?xml version="1.0"?>
<a> 42</a>
test_doc.xml:1: element a: Schemas validity error : Element 'a': ' 42' is not a valid value of the atomic type 'xs:int'.
test_doc.xml fails to validate
According to XML Schema Part 2: Datatypes Second Edition, section 4.3.6 all atomic data types other than 'string' have their 'whiteSpace' constraint set to 'collapse', so I think the element 'a' should be valid.
There is even a comment to this effect in the libxml2 sources (xmlschemas.c / xmlSchemaTypeFixupWhitespace()):
/*
- For all
atomic
datatypes other than string (and typesderived
- by
restriction
from it) the value of whiteSpace is fixed to - collapse */
Edited by Jos de Kloe