XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.

advertisement

The W3C XML Schema Specification in Context
by Rick Jelliffe | Pages: 1, 2, 3, 4, 5

W3C XML Schemas and W3C XML Markup Declarations (DTDs)

W3C XML Markup Declarations (DTDs) are geared to provide simple datatyping on attributes sufficent to support graph-structures in the document only. W3C XML Schemas are intended to provide a systematic datatyping capability. W3C XML DTDs provide a basic macro facility, parameter entities, with which many good effects can be achieved. W3C XML Schemas reconstructs the most common of these in various high-level features.

W3C XML Markup Declarations W3C XML Schema Comments

DOCTYPE Declaration

No equivalent header declaration. A W3C XML Schema has no conception of "document," it operates on elements and attributes which may be in namespaces.

A W3C XML Schema cannot specify the top-level element in any schema. The attribute schemaLocation can be used on elements in instances to name the location of a retrievable schema for that element associated with that namespace.

Internal and External Subset

No equivalent header declaration. However, a schema can be placed within the document that uses it. Schemas can <include>, <import> and <redefine> other schemas, which may be external. There is no mechanism for overriding a declaration in the same schema; however, redefine can be used to restrict or extend declarations from other schemas.

A schema for a single namespace can be composed of several distributed schema documents. Furthermore, a instance may require reference to multiple schemas as it uses elements from different namespaces.

ELEMENT Declaration

An <element> declaration creates a binding between a (namespaced) name and its attributes, content models and annotations.

The big difference between W3C XML DTDs and W3C XML Schemas is the so-called tag/type distinction. This means that there is not a one-to-one correspondence between an element name and its type: for example, it is possible for one complex type to define local types of elements which have precedence over global declarations of an element with the same name. This kind of scoping mechanism is not available in DTDs.

#PCDATA Declared Content Type

Supported by defining a complex type with mixed="true" and no allowed elements.

The simple type string can also be used but caution should be exercised as this may cause problems if ever you need to extend the type to allow subelements.

ANY Declared Content Type

Supported as <any>

<any> has different wildcards to support a richer range of possibilities. Note that <anyAttribute> is also available to allow wildcards on the possible attributes. Whether the subelements found are validated or not, depends on whether the contents are assessed strictly, loosely, or skipped.

EMPTY Declared Content Type

Supported by declaring a complex type with mixed="false" and no allowed subelements.

Note that W3C XML Schemas supports an explicit null as distinct from empty strings. An element (not a type) can be declared null , and a boolean attribute xsi:null on the instance specifies the null value. An implied attribute with no default can be taken as having a null value. There is no way provided to make this usage explicit.

Content Model

Supported as <complexType>.

W3C XML Schemas keeps the W3C XML Markup Declarations requirement for unambiguous content models. Note that W3C XML Schemas maintains XML's model of mixed content, either allowing character data anywhere inside an element or nowhere.

, (Sequence Connector)

Supported. Sequence compositor is the <sequence> grouping element.

 

| (Alternative Connector)

Supported. Disjunction compositor is the <choice> grouping element.

 

? (Optional)

Supported, through maxOccurs and minOccurs attributes on elements, wildcards, and groups.

 

+ (Required and Repeatable)

Supported, through maxOccurs and minOccurs attributes on elements, wildcards, and groups.

 

* (Optional and Repeatable)

Supported, through maxOccurs and minOccurs attributes on elements, wildcards, and groups.

 

( ) (Groups)

Supported by the <group> grouping element

 

ATTLIST Declaration

<attribute> declarations can be grouped into <attributeGroup> declarations.

 

Multiple ATTLIST declarations

Not supported; however, not all attributes need to be defined in the same complex type declaration.

All attribute declarations for a complex type are declared in one place. However, not all of them need to be defined there: they may be defined in an attribute group and declared by reference, or they may belong to the base type.

CDATA Attribute Type

Supported as a built-in simple type "CDATA"

Lexical constraints can be specified using regular expressions in the pattern attribute.

ID Attribute Type

Supported as a built-in simple type.

Lexical constraints on these names can be specified using regular expressions in the pattern attribute. W3C XML Schemas extends the capabilities of ID in the <unique> element, which allows scoping of uniqueness and multipart IDs based on W3C XPaths.

IDREF IDREFS Attribute Types

Supported as built-in simple types.

Lexical constraints on these names can be specified using regular expressions in the pattern attribute. W3C XML Schemas extends the capabilities of IDREF with the <key> and <keyref> elements, which allow scoping of references and multipart keys based on W3C XPaths.

NOTATION Attribute Type

Supported as a built-in simple type.

Lexical constraints on these names can be specified using regular expressions in the pattern attribute.

NMTOKEN NMTOKENS Attribute Types

Supported as built-in simple types.

Lexical constraints on these names can be specified using regular expressions in the pattern attribute.

ENTITY ENTITIES Attribute Types

Supported as a built-in simple type.

Lexical constraints on these names can be specified using regular expressions in the pattern attribute. This refers to entity references as a datatype, not to entity declarations.

Enumerations

Supported

Available on elements as well as attributes.

Attribute Defaults

Supported through the attribute value, a string, and with the attribute use="default".

Available on elements as well as attributes. The syntax is different: use an attribute default of type string.

#FIXED Attributes

Supported through the attribute value, a string, and with the attribute use="default".

Available on elements as well as attributes. The syntax is different: use an attribute fixed of type string.

#REQUIRED and #IMPLIED

Supported through the attribute use, with values "prohibited," "optional," or "required".

 

ENTITY Declaration

Not supported

Entities are declared in W3C XML markup declarations (DTDs).

ENTITY % Parameter Entity Declaration

Not supported. Functionality reconstructed with higher-level constructs.

Parameter entities provide a low-level mechanism useful for many different purposes. W3C XML Schemas has tried to support first-class support for some of the most important:

• the separation of <element> and <complexType>;
• attribute groups;
• named model groups;
• the type extension and restriction mechanisms;
• the <import> , <include> and <redefine> mechanism for composing schemas;
• the element equivalence class mechanism allows redefinition of element names.

General entities can also be used to provide some of the other rarer uses of parameter entities.

XML Schemas 1.0 does not attempt to systematically reconstruct every possible use of parameter entities.

IGNORE/INCLUDE Marked Sections

Not supported

W3C XML Schemas CR does not provide any mechanism equivalent to IGNORE/INCLUDE marked sections. Consequently, if such functionality is required as part of the markup, W3C XML DTDs should be used. However, this functionality can be achieved in other ways: for example, by a schema management application.

NOTATION Declaration

Supported

W3C XML Schemas does not introduce any mechanism for datatyping mixed content data. The underspecified NOTATION mechanism from W3C XML DTDs is supported.

Comments in DTDs

The <documentation> subelement of the <annotation> element provides this functionality. (Comments can still be used.)

<documentation> elements are available to users of the Schema. Comments are not part of the core information set of a document and may not be available or in a useful form.

PIs in DTDs

The <appinfo> subelement of the <annotation> element provides this functionality. (PIs can still be used.)

<appinfo> elements are available to users of the Schema. PIs require knowledge of their notation to parse correctly. Extensions to the XML Schema can be made using <appinfo>. An extension will not change the schema-validity of the document.

 

Pages: 1, 2, 3, 4, 5

Next Pagearrow