Re: XML Schema Question

Helena Cavanagh <helena.cavanagh@usa.net> writes:

> Hello, I have a question regarding the elements that may appear in the
> instances of an XML Schema:
> 
> It seems like there's a price to be paid for using the 'ref' attribute and
> global elements: that all global elements may appear in an instance document.
> Is there a way to restrict this? I would like to say "These are the global
> elements I use in references, and this is the root element I want in the XML
> instances".

I don't understand -- are you referring to substitution groups?  If
so, saying <element name='foo' block='substitution'>...</element> will 
prevent any substitutions.  If not, plese give an example and or
detailed reference to what you don't want.

With respect to root/document element, XML 1.0 doesn't give you this
facility (in DTDs) -- XML Schema does, in that chapter 7 describes how 
to invoke schema validation specifying the starting element
declaration to use.

> I find it confusing that the default number of occurrences of an element is 1
> (minOccurs=maxOccurs=1), while this does not apply to global elements (default
> is "0 or 1", right?):

No, default is 1:1 everywhere.  If there's prose which contradicts
this, please point to it.

> "The consequence of this (global) declaration is that an element called
> comment MAY appear in an instance document" (Primer, Section 2.2)

The relevant schema says <xsd:element ref="comment" minOccurs="0"/>
so 'may' is appropriate.

> Does this mean that the following XML document is valid under po.xsd?
> 
> <?xml version="1.0"?>
> <comment>Is this possible?</comment>

Yes, but see above.

> PS. an extremely minor error in the Primer: the title of section 4.8 is
> "Controlling the Creation...", while in the Table of Contents it appears as
> "Preventing the Creation..."

Thanks, we'll fix that.

ht
-- 
  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, 29 September 2000 16:24:30 UTC