Randy commented on yesterday's post about how I use XSD. He doesn't like the use of multiple global element decls because it makes it unclear which one or ones can be used as the root of a document. I like the GED-centric model because I often want to reuse chunks of XML in multiple places and it feels like the best way to do that.
There is a larger point here, though. I've found in my work that I often want to apply schema for completely different tasks: authoring and validation. Randy's concern is about authoring; making it easy for people to write an instance in XMLSpy or another schema-aware editor. To that end, he wants one GED. I want multiple GEDs because then I can validate any subtree of an instance doc. The real solution to this is actually to do both. We could write two separate schemas, one with multiple GEDs for me and one with a single GED and qualified local element decls (LED) for Randy, that describe the same language.
I've actually taken this path before, writing multiple schemas to validate different aspects of a document at different points in a system. The alternative was to modify the instance document during processing in order to change schema affiliation by redefining the root element or overriding type affiliation using xsi:type. That approach seemed wrong and expensive, so we wrote multiple schemas for the same language instead. The multiple-schema approach works quite well, except that most developers - and the tools they use - don't expect it. Unfortunately, it's hard to write a schema to meet all needs because goals and tools differ. We ended up going back to a single very open schema and a lot of extra validation code written other ways. (One of the things I like about RelaxNG is that there doesn't seem to be the same expectation that there be a single definitive schema for a given language. This is a good thing, but even with RNG, it would be a big shift for people to make.)
If I have to choose between one GED for authoring and many for processing, I'd go with many because I can provide guidance to authors about which GED they should use as their root element(s) other ways. The reverse is not true.
Posted
Aug 25 2004, 06:51 AM
by
tim-ewald