W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2002

Re: Question on use="required"

From: Stanley Guan <stanley.guan@oracle.com>
Date: Thu, 29 Aug 2002 10:46:49 -0700
Message-ID: <0b7601c24f84$0db2e360$c5b42382@us.oracle.com>
To: <www-xml-schema-comments@w3.org>
Cc: <xmlschema-dev@w3.org>

To conclude, there are only the following possibilities:
  1. use="optional" default="1.0"
      valid: <doc /> or
                <doc version="1.0" /> or
                 <doc version="2.0"
  2. use="prohibited" fixed="1.0"
      valid: <doc />
      invalid: <doc version="1.0" /> or
                 <doc version="2.0"
  3. use="required" fixed="1.0"
      valid:   <doc version="1.0" />
      invalid: <doc version="2.0" /> or
                  <doc />
  4. use="optional" fixed="1.0"
      valid: <doc version="1.0" /> or <doc />
      invalid: <doc version="2.0" />

Am I right?

-Stanley

----- Original Message -----
From: "Jeni Tennison" <jeni@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>
Sent: Thursday, August 29, 2002 1:39 AM
Subject: Re: Question on use="required"


>
> 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:complexType>
>     <xs:attribute name="version" type="xs:token"
>                   fixed="1.0" use="required" />
>   </xs:complexType>
> </xs:element>
>
> 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.
>
> Cheers,
>
> Jeni
>
> [1] http://www.w3.org/TR/xmlschema-1/#sic-attrDefault
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
>
Received on Thursday, 29 August 2002 13:51:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:01 GMT