schema parsing errors

Matthias Radestock matthias at
Sat Nov 13 00:26:35 CET 2004

Matthias Radestock wrote:

> I got an error
>   Schema_validator.Schema_facets.Facet_error("minInclusive")
> This is caused by the following xsd:restriction:
>   <xsd:restriction base="xsd:integer">
>     <xsd:minInclusive value="0"/>
>     <xsd:maxInclusive value="3"/>
>   </xsd:restriction>
> Removing the minInclusive element fixed the problem.

I have done some more digging on this.

Here's a more complete example:

   <xsd:complexType name="Compartment">
     <xsd:attribute name="spatialDimensions" use="optional" default="2">
         <xsd:restriction base="xsd:integer">
           <xsd:minInclusive value="0"/>

The error is raised because the validator thinks that the default value 
("2") is smaller than the minInclusive value ("0"). That in turn is 
caused because the former is a Value.string_utf8 whereas the latter is a 
Value.Integer. Clearly the former is wrong; it should be a Value.Integer 

The reason it is a string is that the validator thinks it should parse 
the "2" as an xsd:decimal. xsd:decimal is not supported by CDuce and 
gets parsed to a string. However, obviously the validator should parse 
"2" as an xsd:integer, which would do the right thing, i.e. return a 

For some reason the validator decides to use the *base type* of 
xsd:integer, which happens to be xsd:decimal. The code where this goes 
wrong is the function validate_simple_type in, 
specifically the fragment

   match def with
   | Derived (_, variety, facets, _) ->
       (match variety with
       | Atomic primitive ->
           let validate_base = validate_simple_type primitive in
           let literal = normalize_white_space (fst facets.whiteSpace) s in
           let value = validate_base (Value.string_utf8 literal) in
           Schema_facets.facets_valid facets value;

As you can see, primitive is the type against which the value is 
validated/parsed. It is xsd:decimal. The type we want, xsd:integer, is 
in the last slot of the Derived value (i.e. Derived (_, variety, facets, 
base)). That would obviously be easy to fix. However, perhaps the real 
problem is that the value of primitive is wrong, i.e. that it should be 
xsd:integer instead of xsd:decimal. Can somebody tell me whether that is 
the case?


More information about the Cduce-users mailing list