RE: Defining recursive elements?

> 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
http://www.saxonica.com/

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