-- Ron Bourret
4 XSchema Documents and DTDs=0D
=0D
An XSchema document is related to two different DTDs: the DTD of the =
XSchema=20
document itself and the DTD of the document described by the XSchema =
document.=20
This section discusses the relationship of XSchema documents to these =
DTDs and=20
describes what conversions are possible between the XSchema document and =
the=20
latter DTD. There is no requirement that either DTD actually exist.=0D
=0D
4.1 DTDs in XSchema Documents=0D
=0D
An XSchema document may include a DTD as an internal subset, external =
subset, or=20
both. If included, this DTD must include all of the markup declarations =
in=20
Appendix B, "XSchema DTD." It may also include additional markup =
declarations,=20
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=20
XML parser can supply default attribute values and determine the system =
and=20
public identifiers of notations and unparsed general entities. Default =
attribute=20
values are used in the XSchema DTD defined in Appendix B. Notations and =
unparsed=20
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=20
parsed entities (see Section 5.2.1, "Parsed Entities in XSchema =
Documents") and=20
to allow the document to be validated by XSchema-unaware software.=20
4.2 DTDs in Documents Described by XSchema Documents=0D
=0D
A document described by an XSchema document may include a DTD as well as =
=20
processing instructions that refer to XSchema documents (see section =
5.1.1,=20
"XSchema Processing Instruction"). This DTD can describe the same =
information as=20
the XSchema documents as well as additional information.
The main reason to include a DTD in a document described by an XSchema =
document=20
is so an XSchema-unaware XML parser can supply default attribute values =
and=20
determine the system and public identifiers of notations and unparsed =
general=20
entities. Secondary reasons are so that the document can be used with =
both=20
XSchema-aware and -unaware software, to define the root element in the =
document,=20
and to declare parsed general entities.
=0D
If an XML document includes both a DTD and processing instructions that =
refer to=20
XSchema documents, it is the responsibility of the document author to =
ensure=20
that the information common to both is the same. If the common =
information is=20
different, it might not be possible to use the document with both =
XSchema-aware=20
and -unaware software. For example, it might not be possible to validate =
the=20
document against both the DTD and the XSchema documents.=0D
=0D
If an XSchema processor is built on top of an XML parser, the XSchema =
processor=20
is not required to process the DTD of the XML document. If an XSchema =
processor=20
also functions as an XML parser, it is required to process the DTD only =
to the=20
extent required of a non-validating parser.=0D
=0D
4.3 Converting Between XSchema Documents and DTDs=0D
=0D
Schema information can be converted between XSchema documents and DTDs, =
although=20
some information may be lost. Most logical information (such as element =
and=20
attribute declarations) can be converted from DTDs to XSchema documents, =
while=20
some logical information (such as attribute declarations not assigned to =
=20
elements) cannot be converted from XSchema documents to DTDs. In =
general,=20
physical information (such as parsed entity declarations and use, the =
order of=20
declarations, and the distribution of declarations among different =
files) either=20
cannot be converted or is converted only at the option of the converter.=0D=
=0D
4.3.1 Converting DTDs to XSchema Documents=0D
=0D
The following DTD structures must be converted to the corresponding =
XSchema=20
structures:=0D
=0D
* Element, attribute, notation, and unparsed entity declarations. The =
order of=20
the resulting elements, including whether attribute declarations are =
placed=20
inside element declarations, is the choice of the converter.=0D
=0D
* Namespace prefixes in element and attribute declarations. These must =
be=20
stripped from the element or attribute name and stored in the =
appropriate=20
attribute (prefix or ElementPrefix). The converter may prompt the user =
for the=20
URI of the namespace to be stored in the corresponding ns or ElementNS=20
attribute.=0D
=0D
The following DTD structures may be converted to the corresponding =
XSchema=20
structures or discarded:=0D
=0D
* Comments. These may be converted to Doc elements. The position of =
resulting=20
Doc elements in the XSchema document is the choice of the converter. For =
=20
example, a converter might place comments in a Doc element inside the =
following=20
element, attribute, notation, or unparsed entity declaration.=0D
=0D
* Parameter entity declarations and use. These may be converted to =
parsed=20
general entity declarations and use.=0D
=0D
The following DTD structures cannot be converted to XSchema structures =
because=20
such structures do not exist:=0D
=0D
* Duplicate attribute and unparsed entity declarations.=0D
=0D
* Parsed general entity declarations and use.=0D
=0D
* Conditional sections in external parameter entities.=0D
=0D
QUESTION: What happens to the following:=0D
* Processing instructions=0D
* Text encoding declarations=0D
=0D
4.3.2 Converting XSchema Documents to DTDs=0D
=0D
The following XSchema structures must be converted to the corresponding =
DTD=20
structures:=0D
=0D
* All information in element, notation, and unparsed entity declarations =
and=20
attribute declarations that apply to a particular element, except as =
noted=20
elsewhere. The order of the resulting declarations is the choice of the=20
converter.=0D
=0D
* Namespace prefixes declared in prefix and ElementPrefix attributes. =
These must=20
be prepended to the element or attribute name.=0D
=0D
The following XSchema structures may be converted to the corresponding =
DTD=20
structures or discarded:=0D
=0D
* Doc elements. These may be converted to comments. The position of =
resulting=20
comments in the DTD is the choice of the converter.=0D
=0D
* Parsed entities declared in the DTD of the XSchema document. These may =
be=20
converted to parsed general entities or parameter entities as =
appropriate.=0D
=0D
The following XSchema structures cannot be converted to DTD structures =
because=20
such structures do not exist:=0D
=0D
* More elements, AttDef and AttGroup elements that do not apply to a =
particular=20
element, and Model and Enumeration elements nested directly beneath an =
XSchema=20
element.=0D
=0D
* All id attributes, all attributes of the XSchema element except for =
prefix,=20
all ns and ElementNS attributes, and the Root attribute of the =
ElementDecl=20
element.=0D
=0D
* Nesting of schema information provided by nested XSchema elements.=0D
=0D