Chapter 5. Flattening the First Schema
If you look at the structure of the Russian doll-style
schema, you’ll see that it
follows the structure of the instance document it applies to, as
shown in Figure 3-1. Writing the first
schema has pretty much been limited to inserting
text, element, or
attribute elements into the schema each time a
text node, element, or attribute was encountered in the instance
document. This method of creating schemas can be seen as a
serialization of the XML infoset
(i.e., of the structure available in the document) and could,
therefore, be easily automated.
Tip
Automated serialization is the principle behind Examplotron, a program described in Chapter 14.
There are a couple of drawbacks to modeling documents with the Russian doll-style schemas, however. First, they aren’t modular and therefore become difficult to read and maintain when documents are large or complex. Second, they can’t represent recursive (self-referencing) models. (Lists that may themselves contain lists are a common case of this model.)
The lack of modularity can be seen in a document as simple as the
first schema, shown in Example 3-1.
There’s a name element that uses
the same model within both the character and
author elements.
Figure 5-1 shows how, in the first schema, you need
to give the definition of what name means in each
context:
![]() |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access
