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

Re: Question on use="required"

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 29 Aug 2002 19:04:45 +0100
Message-ID: <1571485290825.20020829190445@jenitennison.com>
To: xmlschema-dev@w3.org, "Stanley Guan" <stanley.guan@oracle.com>
CC: www-xml-schema-comments@w3.org

Hi Stanley,

> 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"

Yep.

>   2. use="prohibited" fixed="1.0"
>       valid: <doc />
>       invalid: <doc version="1.0" /> or
>                  <doc version="2.0"

Nope. use="prohibited" is only used when you're deriving a type by
restriction and you want to say "elements of this type cannot have
this attribute". When you derive a type by restriction, all the
attributes from the base type are inherited by the restricted type
*unless* you specify use="prohibited". If you try to specify a default
or fixed value on an xs:attribute with use="prohibited", it'll just
get ignored.

>   3. use="required" fixed="1.0"
>       valid:   <doc version="1.0" />
>       invalid: <doc version="2.0" /> or
>                   <doc />

Yep.

>   4. use="optional" fixed="1.0"
>       valid: <doc version="1.0" /> or <doc />
>       invalid: <doc version="2.0" />

Yep.

So in fact there are five combinations if you include ones without
value constraints:

  optional without default or fixed value
  optional with default value
  optional with fixed value
  required without default or fixed value
  required with fixed value

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Thursday, 29 August 2002 14:04:52 GMT

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