Re: [xmlschema-dev] <none>

Paul Jakubik <pauljakubik@yahoo.com> writes:

> I am trying to understand what the XML Schema PR has
> to say about using default and fixed when specifying
> attributes and elements.
> 
> This is what I think is true about default and fixed
> in attributes (please correct me if I am wrong):
> ----------------------------------------------------
> 1)If an attribute has a default value specified, the
> attribute's use can not be required. 
> 
> 2)If the attribute is fixed, then its use may be
> required or optional.
> 
> 3)If the attribute does not appear, the default or
> fixed value will be used for that attribute (when
> parsing with a validating parser, the parse results
> should make it appear that the attribute was provided
> and using the default or fixed value).

All correct.

> I am a little more confused with the behavior of
> default and fixed for elements, so I have some
> questions:
> --------------------------------------------------
> Q1: The primer says that if a default is provided,
> minOccurs must be 0 for that element. I could not find
> anything in the structure document that says the same
> thing. Could someone point me to the appropriate part
> of the PR?

There isn't any, because element defaults are about content, see below.
See [1], clause 5.1.

> Q2: The default value should be used when the element
> is empty. Should the default value also be used when
> the element does not appear in the document being
> validated?

No, that's a difference between elements and attributes.

> Q3: If the answer to Q2 is no, then why require
> minOccurs to be 0 if a default is specified.

You've uncovered a mistake in the Primer, thanks.

> Q4: Does fixed work the same way in elements as it
> does in attributes? If a fixed value is specified for
> an element, should that value be used if the element
> is missing or empty?

Yes.  See [1], clause 5.1 again, and also clause 5.2

Hope this helps.

ht
[1] http://www.w3.org/TR/xmlschema-1/#cvc-elt
-- 
  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
          W3C Fellow 1999--2001, part-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
	    Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
		     URL: http://www.ltg.ed.ac.uk/~ht/

Received on Friday, 20 April 2001 04:53:15 UTC