Re: [xml] XSD Schema validation issues with boolean type.



On Mon, Feb 20, 2006 at 01:29:32PM +1000, Bas Driessen wrote:
Hello,

I am using the latest version of libxml2 (2.6.23) and have an issue with
validation boolean type fields using "xmllint --schema". If I have an
XML file as follows:

<TestRoot xmlns="urn:Test-schema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:schemaLocation="urn:Test-schema Test.xsd">
  <Boolean1>true</Boolean1>
  <Boolean2>xtrue</Boolean2>
  <Boolean3>   true   </Boolean3>
  <Boolean4/>
</TestRoot>

My understanding is that only Boolean1 should validate OK and the other
3 cases should fail. My test.xsd is as follows:

<xs:schema xmlns="urn:Test-schema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"; id="Test" version="1"
targetNamespace="urn:Test-schema" elementFormDefault="qualified">
<!-- Root -->
  <xs:element name="TestRoot">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="Boolean1" type="xs:boolean"/>
        <xs:element name="Boolean2" type="xs:boolean"/>
        <xs:element name="Boolean3" type="xs:boolean"/>
        <xs:element name="Boolean4" type="xs:boolean"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

The output of xmllint however is as follows:

test.xml:4: element Boolean2: Schemas validity error : Element
'{urn:Test-schema}Boolean2': 'xtrue' is not a valid value of the atomic
type 'xs:boolean'.
test.xml fails to validate

So it only picks up the problem in situation 2, while situation 3 and 4
is not being picked up as a problem.

  http://www.w3.org/TR/xmlschema-2/#boolean

there is a 'whiteSpace' constraining facet, so I think Boolean3 might validate
For Boolean4 this looks like a bug to me. Also note that '1' and '0' are 
accepted values for this type. 
Kasimier certainly has a more precise idea about this. I'm surprized this
kind of problem isn't caught by the huge OASIS datatype regression tests.

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]