W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2007

RE: Defining recursive elements?

From: Michael Kay <mike@saxonica.com>
Date: Thu, 17 May 2007 23:17:30 +0100
To: "'Todd Moon'" <tmrfcm@gmail.com>, <xmlschema-dev@w3.org>
Message-ID: <019e01c798d1$291690c0$6401a8c0@turtle>

> With global definitions some documents will be valid that you might 
> not want, for example an XML document of just <header/> 
> would validate using that schema.

I think it's a mistake to make elements local simply because you think there
will never be a requirement to use them as a validation root. In principle a
schema validator should give you the opportunity to say what element
declaration you want to validate against when you invoke validation.
Admittedly not all products offer that ability (Saxon doesn't, except via
some very low level API calls, until the next release), but they should. In
the meantime it's not really that hard to apply two conditions: (a) the
document must be valid, and (b) its outermost element must be X.

Again, once you start using schema-aware queries and stylesheets you find
yourself validating at a much finer level of granularity, and if you haven't
left that possibility open in the schema, then you're constrained. In XSLT
you can always validate against a global type instead, but even that option
isn't available in XQuery.

Michael Kay
Received on Thursday, 17 May 2007 22:17:39 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:12 UTC