Re: What's a valid instance...James Clark

On 22 Mar 2007, at 08:43 , Shlomo Yona wrote:

> If the XML Schema defines more than one element globally then any such
> globally defined element can be a valid root to an XML instance  
> document
> of that XML Schema definition.

Yes.  And similarly, any global element may be referred to from
content models in other namespaces, so any global element is a
potential point of re-use of the schema.

It's quite true that to describe fully and tightly the language
you want to accept, you will want to specify the root element,
just as when you define a language using a notation like EBNF you
will need to specify which non-terminal is the start-symbol.

But it's a mistake to believe that the best place to do this is
in the schema document.  The spec is very clear (section 5.2)
that you may wish to start validation by saying "the root element
has to match *this* top-level element declaration", or "... this
top-level type definition", or by saying that lax validation is
OK, and so on.

The claim that XSD is flawed because it says you should identify
the start-element as part of starting validation rather than in
the schema document is bogus, equivalent to the claim that the
extended BNF used by the XML spec is flawed because it does not
indicate which non-terminal is the start-symbol.

If your processor defaults to a validation mode you don't want,
then use invocation-time options to specify the mode you do
want.  If your processor doesn't allow you to specify the mode
you want, then get a new processor.

> Is this intentional? I mean -- I couldn't find a way to restrict a  
> sole
> root to the document.

Very intentional.  See section 5.2 of the spec.

--C. M. Sperberg-McQueen

Received on Thursday, 22 March 2007 15:25:33 UTC