W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2002

Re: Derivation of facet values

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 30 Jul 2002 10:53:15 +0100
Message-ID: <1932066910980.20020730105315@jenitennison.com>
To: Rainer Becker <r.becker@Nitro-Software.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi Rainer,

> (a) If you take into account, that the Datatypes Spec states the following
> for the minLength facet:
>
>     Schema Component Constraint: minLength valid restriction 
>
> ----------------------------------------------------------------------------
> ----------
>     It is an ·error· if minLength is among the members of {facets} 
>     of {base type definition} and {value} is less than the {value} of the 
>     parent minLength
>
> It was ok for me, that MSXML Core Services SP1 cites the
> above sentence, together with the following schema.
>
>  --- snip ----
>
>    <xsd:simpleType name="string_len8">
>       <xsd:restriction base="xsd:string">
>          <xsd:minLength value="8" />
>          <xsd:maxLength value="8" />
>       </xsd:restriction>
>    </xsd:simpleType>
>
>    <xsd:simpleType name="string_len4">
>       <xsd:restriction base="string_len8">
>          <xsd:minLength value="4" />
>          <xsd:maxLength value="8" />
>       </xsd:restriction>
>    </xsd:simpleType>
> </xsd:schema>

Presumably MSXML says that this schema is invalid because the
minLength in the restriction is less than the minLength in the base
type.

> But if I use length, instead of minLength and maxLength, MSXML has
> got no problems with it.
>
> --- snip ---
>
>    <xsd:simpleType name="string_len8">
>       <xsd:restriction base="xsd:string">
>          <xsd:length value="8" />
>       </xsd:restriction>
>    </xsd:simpleType>
>
>     <xsd:simpleType name="string_len4">
>       <xsd:restriction base="string_len8">
>          <xsd:length value="4" />
>       </xsd:restriction>
>    </xsd:simpleType>
> </xsd:schema>

Schema validators should complain about this schema, since the length
in the restricted type is not equal to the length in the base type. If
MSXML doesn't complain, then it has a bug.

> (1) I thought, that "Schema Component Constraints" were constraints
> on the "internal representation of the schema". But in case of the
> facets, doesnīt it make sense that these constraints "restrict" the
> XML Representation aswell?. In case of minLength it does.....
>
> Why does the headline say "Schema Component Constraint" ?

The headline says "Schema Component Constraint" because if you created
a simple type without ever having an XML representation of the schema,
it would still be the case that that simple type's minLength facet had
to be less than the value of the minLength facet on its base type.

Since there's a one-to-one mapping from an XML representation of a
schema to a set of schema components, naturally the constraints at the
schema component level have an effect on what you can write in the
physical schema. The constraints on a physical schema are a
combination of those on the XML representation and those on the schema
components that would be generated from that physical schema.

> (2) Isnīt it at least inconsistent, if the Schema Component
> Constraint for a valid restriciton of minLength results in an error
> message, while the the same constraint for the length facet does
> not?

Yes, it's a bug in MSXML.

> (3) Provided that, the behaviour for the "minLength valid
> restriction" conforms to the spec, why would I need a fixed
> attribute on most facets?
     
Setting fixed to true means that derived types can't change the value
of the facet. For example, if you had:

<xsd:simpleType name="string_len4">
  <xsd:restriction base="xsd:string">
    <xsd:minLength value="4" fixed="true" />
    <xsd:maxLength value="8" />
  </xsd:restriction>
</xsd:simpleType>

then you couldn't derive the type:

<xsd:simpleType name="string_len4">
  <xsd:restriction base="string_len8">
    <xsd:minLength value="8" />
    <xsd:maxLength value="8" />
  </xsd:restriction>
</xsd:simpleType>

despite the fact that it meets the constraint that the minLength on
the derived type can't be less than the minLength on the base type.

To be honest, I find it hard to think of examples where fixing a facet
is actually useful; the only examples in the schema for XML Schema or
in the Primer are on facets that cannot be restricted any further due
to other constraints. Does anyone have a use case that they can share?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 30 July 2002 05:53:33 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:57 UTC