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

Re: Question on use="required"

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 29 Aug 2002 09:39:03 +0100
Message-ID: <1841451350371.20020829093903@jenitennison.com>
To: "Dare Obasanjo" <dareo@microsoft.com>
CC: "Stefan Wachter" <Stefan.Wachter@gmx.de>, xmlschema-dev@w3.org, www-xml-schema-comments@w3.org

Hi Dare,

> However although provisions are made to prevent use="required" and
> the default value being present in the attribute declaration from
> occuring[1] no similar provision is made for use="required" and the
> fixed value being set. It is my opinion that this is likely an
> oversight and clarification from the W3C XML Schema working group is
> needed.
> In writing the disputed conformance test we were of the opinion that
> since fixed modifies the PSVI and inserts an attribute information
> item where there was none before then having use="required" is
> redundant and a NO-OP.

I disagree. In "Schema Information Set Contribution: Attribute Default
Value" [1] it says:

  For each attribute use in the {attribute uses} whose {required} is
  false and whose {value constraint} is not ·absent· but whose
  {attribute declaration} does not match one of the attribute
  information items in the element information item's [attributes] as
  per clause 3.1 of Element Locally Valid (Complex Type) (§3.4.4)
  above, the post-schema-validation infoset has an attribute
  information item whose properties are as below added to the
  [attributes] of the element information item.

Two things here:

  1. a default or fixed attribute is only added to the PSVI if its
     *required is false* and it is missing

  2. it gets added to the PSVI, not to the original infoset the
     validity of which is being assessed

So a fixed attribute will only modify the PSVI if it isn't required --
it won't get added if it is required, and therefore having
use="required" is not a NO-OP. Plus it would get added to the *PSVI*
anyway, which means it has no effect on the schema validity
assessment, which occurs on the original infoset, not the PSVI.

Therefore if I have a schema that declares:

<xs:element name="doc">
    <xs:attribute name="version" type="xs:token"
                  fixed="1.0" use="required" />

then the only valid doc element is:

  <doc version="1.0" />

Both following doc elements are invalid:

  <doc version="2.0" />
  <doc />

the first because the version attribute does not have the fixed value
and the second because the version attribute is missing; the version
attribute is not added to the PSVI (since it's required), but even if
it were, it's the original infoset that's being assessed at this
point, and that lacks a version attribute, which is required, and it's
therefore invalid.



[1] http://www.w3.org/TR/xmlschema-1/#sic-attrDefault

Jeni Tennison
Received on Thursday, 29 August 2002 04:39:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:05 UTC