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

Re: Question on use="required"

From: Stefan Wachter <Stefan.Wachter@gmx.de>
Date: Wed, 14 Aug 2002 16:25:02 +0200 (MEST)
To: Jeni Tennison <jeni@jenitennison.com>; xmlschema-dev@w3.org
Message-ID: <10601.1029335102@www30.gmx.net>

Hi Jeni,

I agree with your answer that in the instance document there must appear a
value for an attribute whose use is required. But I think it would be good to
allow value constraints for such attributes in the schema for two reasons:

1. If I want to express that an attribute must be present and have a certain
value.

2. There is a great schema which I import and which contains value
constraints for various declarations. Some people (like me) do not like default values
and want that an instance author must specify all values. Therefore I would
restrict the imported declarations by adding the use="required" attribute.
These declarations would now have value constraints and the use="required"
attribute.


--Stefan

PS:  So there is an error in the Microsoft testcase attribute/attP009.xsd.
Theres is the complexType

	<xsd:complexType name="attRef">
		<xsd:attribute name="att" use="required" fixed="37"/>
	</xsd:complexType>

which is valid. But in the accompanying instance document attP009.xml there
is no value for the attribute.


> Hi Stefan,
> 
> > I have a question regarding attribute declarations whose use
> > attribute has the value "required". Must there be values for such
> > attributes in instance documents or is it also allowed to have a
> > fixed/default values filled in?
> 
> The instance document must specify a value for the attribute [1]. I
> *think* that you're not allowed to specify a default value for a
> required attribute in the schema, because default values only apply
> when the attribute is missing, and if it's required it can't be
> missing, but I can't find the constraint specifying that at the
> moment. You can have fixed values for required attributes, however
> (particularly useful for indicating the version of a markup language).
> 
> Cheers,
> 
> Jeni
> 
> [1] Clause 4 of http://www.w3.org/TR/xmlschema-1/#cvc-complex-type
> 
> ---
> Jeni Tennison
> http://www.jenitennison.com/
> 
Received on Wednesday, 14 August 2002 10:25:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT