XSchema: Section 4

Ron Bourret rbourret at dvs1.informatik.tu-darmstadt.de
Wed Sep 23 01:05:41 BST 1998


Here is the long rumored section 4, which discusses the interaction of XSchema documents and 
DTDs and how to convert between the two.  An HTML version will be available in a 
day or two.  Please send comments to the list or directly to me 
(rbourret at dvs1.informatik.tu-darmstadt.de).

-- Ron Bourret


4 XSchema Documents and DTDs

An XSchema document is related to two different DTDs: the DTD of the XSchema 
document itself and the DTD of the document described by the XSchema document. 
This section discusses the relationship of XSchema documents to these DTDs and 
describes what conversions are possible between the XSchema document and the 
latter DTD. There is no requirement that either DTD actually exist.

4.1 DTDs in XSchema Documents

An XSchema document may include a DTD as an internal subset, external subset, or 
both. If included, this DTD must include all of the markup declarations in 
Appendix B, "XSchema DTD." It may also include additional markup declarations, 
such as declarations of elements to be used under the More element.

The main reason to include a DTD in an XSchema document is so an XSchema-unaware 
XML parser can supply default attribute values and determine the system and 
public identifiers of notations and unparsed general entities. Default attribute 
values are used in the XSchema DTD defined in Appendix B. Notations and unparsed 
general entities can be used by user-defined elements under the More element.

Secondary reasons for including a DTD in an XSchema document are to declare 
parsed entities (see Section 5.2.1, "Parsed Entities in XSchema Documents") and 
to allow the document to be validated by XSchema-unaware software. 

4.2 DTDs in Documents Described by XSchema Documents

A document described by an XSchema document may include a DTD as well as  
processing instructions that refer to XSchema documents (see section 5.1.1, 
"XSchema Processing Instruction"). This DTD can describe the same information as 
the XSchema documents as well as additional information.

The main reason to include a DTD in a document described by an XSchema document 
is so an XSchema-unaware XML parser can supply default attribute values and 
determine the system and public identifiers of notations and unparsed general 
entities. Secondary reasons are so that the document can be used with both 
XSchema-aware and -unaware software, to define the root element in the document, 
and to declare parsed general entities.

If an XML document includes both a DTD and processing instructions that refer to 
XSchema documents, it is the responsibility of the document author to ensure 
that the information common to both is the same. If the common information is 
different, it might not be possible to use the document with both XSchema-aware 
and -unaware software. For example, it might not be possible to validate the 
document against both the DTD and the XSchema documents.

If an XSchema processor is built on top of an XML parser, the XSchema processor 
is not required to process the DTD of the XML document. If an XSchema processor 
also functions as an XML parser, it is required to process the DTD only to the 
extent required of a non-validating parser.

4.3 Converting Between XSchema Documents and DTDs

Schema information can be converted between XSchema documents and DTDs, although 
some information may be lost. Most logical information (such as element and 
attribute declarations) can be converted from DTDs to XSchema documents, while 
some logical information (such as attribute declarations not assigned to  
elements) cannot be converted from XSchema documents to DTDs. In general, 
physical information (such as parsed entity declarations and use, the order of 
declarations, and the distribution of declarations among different files) either 
cannot be converted or is converted only at the option of the converter.

4.3.1 Converting DTDs to XSchema Documents

The following DTD structures must be converted to the corresponding XSchema 
structures:

* Element, attribute, notation, and unparsed entity declarations. The order of 
the resulting elements, including whether attribute declarations are placed 
inside element declarations, is the choice of the converter.

* Namespace prefixes in element and attribute declarations. These must be 
stripped from the element or attribute name and stored in the appropriate 
attribute (prefix or ElementPrefix). The converter may prompt the user for the 
URI of the namespace to be stored in the corresponding ns or ElementNS 
attribute.

The following DTD structures may be converted to the corresponding XSchema 
structures or discarded:

* Comments. These may be converted to Doc elements. The position of resulting 
Doc elements in the XSchema document is the choice of the converter. For  
example, a converter might place comments in a Doc element inside the following 
element, attribute, notation, or unparsed entity declaration.

* Parameter entity declarations and use. These may be converted to parsed 
general entity declarations and use.

The following DTD structures cannot be converted to XSchema structures because 
such structures do not exist:

* Duplicate attribute and unparsed entity declarations.

* Parsed general entity declarations and use.

* Conditional sections in external parameter entities.

QUESTION: What happens to the following:
* Processing instructions
* Text encoding declarations

4.3.2 Converting XSchema Documents to DTDs

The following XSchema structures must be converted to the corresponding DTD 
structures:

* All information in element, notation, and unparsed entity declarations and 
attribute declarations that apply to a particular element, except as noted 
elsewhere. The order of the resulting declarations is the choice of the 
converter.

* Namespace prefixes declared in prefix and ElementPrefix attributes. These must 
be prepended to the element or attribute name.

The following XSchema structures may be converted to the corresponding DTD 
structures or discarded:

* Doc elements. These may be converted to comments. The position of resulting 
comments in the DTD is the choice of the converter.

* Parsed entities declared in the DTD of the XSchema document. These may be 
converted to parsed general entities or parameter entities as appropriate.

The following XSchema structures cannot be converted to DTD structures because 
such structures do not exist:

* More elements, AttDef and AttGroup elements that do not apply to a particular 
element, and Model and Enumeration elements nested directly beneath an XSchema 
element.

* All id attributes, all attributes of the XSchema element except for prefix, 
all ns and ElementNS attributes, and the Root attribute of the ElementDecl 
element.

* Nesting of schema information provided by nested XSchema elements.


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list