An HTML version will be available in a day or two. Please send comments =
to the=20
list or directly to me (rbourret@dvs1.informatik.tu-darmstadt.de).
-- Ron Bourret
5 Using XSchema Documents
This section describes how to associate XSchema documents with XML =
documents and=20
suggests ways to use XSchema documents.
=0D
5.1 Associating XSchema Documents with XML Documents=0D
=0D
An XSchema document can define a class of XML documents in the same way =
a DTD=20
defines a class of XML documents. A document declares that it conforms =
to a=20
class by including the XSchema processing instruction. A document =
fragment can=20
declare that it conforms to a class by including a nested XSchema =
element; this=20
latter usage is experimental.
=0D
5.1.1 XSchema Processing Instruction=0D
The XSchema processing instruction is similar to the SYSTEM declaration =
in a=20
DOCTYPE statement. It states that the document conforms to the class of=20
documents described by the XSchema document. The processing instruction =
has the=20
following form:
[1] XSchemaPI ::=3D '<?xschema' S XSchemaID S? '?>'
[2] XSchemaID ::=3D 'xschema' Eq SystemLiteral
where S, Eq, and SystemLiteral are the same as in [XML].
An XSchema processing instruction must occur before the root element to =
be used;=20
any XSchema processing instructions that occur after the root element =
will be=20
ignored.
An XML document may include multiple XSchema processing instructions. =
The effect=20
is as if a superior root XSchema element contains the root XSchema =
element of=20
each XSchema document. This allows a document to conform to elements in =
many=20
existing XSchema documents. For more information, see Section 5.2.5, =
"Reusing=20
Element Declarations with Entities or Processing Instructions."
=0D
5.1.2 Inline XSchema Elements (Non-Normative)=0D
NOTE: Inline XSchema elements are considered experimental and may change =
in the=20
future.
In some applications it is useful to repeatedly change the schema of the =
XML=20
document at run time.=0DFor example, consider a system that continuously =
logs data=20
in XML format. From an XML standpoint, it is as if a root element was =
started=20
when the system was started, all incoming information is nested beneath =
the root=20
element, and the root element ends only when the system is stops. For =
practical=20
purposes, the root element might not actually exist.
If the system logs information from different sources, the format =
(schema) of=20
the nested elements might be different for each source. XSchema elements =
can be=20
interspersed in this stream to describe the format of following =
information:
<Root>
<XSchema>...schema #1...</XSchema>
...log information that conforms to schema #1...
<XSchema>...schema #2...</XSchema>
...log information that conforms to schema #2...
...
</Root>
Because such use is not well-defined today, XSchema processors that use =
inline=20
XSchema elements should follow these rules for the greatest chance of =
forward=20
compatibility:
* The schema information in an XSchema element applies to all following =
elements=20
at the same level until the next XSchema element at that level is =
encountered.
* The schema information in an XSchema element completely replaces the =
schema=20
information in the previous XSchema element at the same level. That is, =
no=20
partial replacement of schema information is allowed.