HomeXML Page 5 - Doing More With XML Schemas (part 2)
Speaking In The Abstract - XML
In this second part, find out how to derive new element types by constraining existing ones, control access to your schema definitions, and redefine externally-provided schemas in place.
While on the subject of controlling the manner in which type definitions can be used, it's instructive to also look at abstract type definitions. If a base type spawns several new sub-types, as in the example below,
This requires document authors to specifically name the sub-type whenever they
use it in a document instance. Failure to do so will result in XML validation errors. For example, while the following XML document instance is certainly conformant to the rules laid down for the base type "starWarsEntity",
the XML validator will still generate errors while parsing it, as "starWarsEntity"
has been defined as an abstract type. It is only when the document author specifies a type via the "type" attribute
Again, this mechanism assists in reducing the risk of errors, and in controlling the manner in which schema definitions are used by document authors. It's also possible to declare specific elements (rather than types) as abstract - all you need is a substitution group, which you can read about at http://www.w3.org/TR/xmlschema-0/#SubsGroups