W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2001

Re: Simple question on elements constraints

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 25 Jan 2001 08:20:01 +0000
To: Michael Anderson <michael@research.canon.com.au>
Cc: francis@redrice.com, Adalbert Wysocki <waldi@imediation.com>, xmlschema-dev@w3.org
Message-ID: <f5b66j411se.fsf@cogsci.ed.ac.uk>
Michael Anderson <michael@research.canon.com.au> writes:

> Francis Norton wrote:
> <snip>
> 
> > The second question has to do with defaults. "fixed" and "default" only
> > apply to attribute declarations (see
> > http://www.w3.org/TR/xmlschema-0/#ref36) and are specified via the "use"
> > and "value" attributes, eg you could add:
> >
> >       <xsd:attribute name="weather" use="fixed" value="wet" />
> >
> > after the </xsd:sequence> above, and while both XML Spy 3.5 and xsv will
> > allow the "weather" attribute to be absent, neither will allow it to be
> > empty or to have any value but "wet".
> 
> Sorry, my previous mail was a bit verbose.  My main problem has to do with
> the above example applied to an element.  If I have:
> 
> <xsd:element name="weather" fixed="wet"/>
> 
> and an information item
> 
> <weather></weather>
> 
> Is the "weather" content considered to be absent, thus be allowed, and given
> a value of "wet"?
> OR
> Is the "weather" content considered empty, thus not be allowed?

There is no difference between absent and empty.  The infoset for that
element has no children.  So following clauses [1] [2] will apply,
_provided_ the element has a simple type definition, e.g. you need to
modify your example slightly to

 <xs:element name="weather" type="xs:token" fixed="wet"/>

  If the declaration has a {value constraint}, then provided clause
  1.2.2 has not obtained . . .
   3.2 
     If the {value constraint} is fixed, the element information item
     must have no element information item [children], and the
     normalized value must be either empty or match the string of the
     {value constraint};

   If an element information item is valid with respect to an element
   declaration as per Element Locally Valid (Element) (3.3) and the
   {value constraint} is present, but clause 1.2.2 of Element Locally
   Valid (Element) (3.3) above does not obtain and the element
   information item has no element or character information item
   [children], the post-schema-validation infoset has the {value
   constraint}'s string as the item's [schema normalized value]
   property and its [specified] is set to schema. Otherwise, the
   item's [specified] is set to instance.

ht

[1] http://www.w3.org/TR/xmlschema-1/#cvc-elt
[2] http://www.w3.org/TR/xmlschema-1/#sic-eltDefault
-- 
  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 Thursday, 25 January 2001 03:20:36 GMT

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