|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
WebWriter has played it safe in allowing every element to have mixed content (#PCDATA is allowed in all the content models), and it was wise not to guess about the nature of the element attributes. This gives you a good framework for your DTD. To complete it, you can tighten up the content models and fill in the attribute declarations. One possible end result is shown in Listing 14.4. Listing 14.4 Home.dtdFinal Home.dtd DTD <?xml version = 1.0?> <!ELEMENT home.page (head | body | footer)> <!ELEMENT head (title | banner?)> <!ELEMENT title (#PCDATA)> <!ELEMENT banner EMPTY> <!ATTLIST banner src CDATA #REQUIRED alt CDATA #IMPLIED align (top | middle | bottom) #IMPLIED> <!ELEMENT body(main.title |rule | text)> <!ELEMENT main.title (#PCDATA)> <!ELEMENT rule EMPTY> <!ATTLIST rule align (left|right|center) #IMPLIED size NMTOKEN #IMPLIED width CDATA #IMPLIED > <!ELEMENT text(#PCDATA | para)*> <!ELEMENT para(#PCDATA)> <!ELEMENT footer EMPTY> <!ATTLIST footer src CDATA #REQUIRED alt CDATA #IMPLIED align (top|middle|bottom) #IMPLIED> <!ENTITY lt <> <!ENTITY gt >> <!ENTITY apos > <!ENTITY quot > <!ENTITY amp &>
Richness and EntropyIf you want to do something with a piece of information in an XML document, you must identify it. It doesnt matter whether you mark it up using elements or attributes, but if you havent marked it up, you either wont be able to find it at all, and even if you can find it, you wont be able to do anything with it. A DTD that contains a lot of (informative) markup is called a rich DTD. As the DTD designer, you will always face a difficult compromise between the complexity of the DTD and the information richness of XML documents that conform to that DTD. Where humans are the authors of those documents, the complexity of the DTD can become a major obstacle. When you have the room to make choices, always choose the richest information model you can:
Visual ModelingEarlier in this chapter, you learned that one of the basic DTD design process steps is to construct the hierarchy, to use the content models in the DTD to arrange the elements in an XML document that uses the DTD in a hierarchical, tree-like structure. Many information modeling techniques are available, but detailed discussion of them falls outside the scope of this book. What is of interest to us here is that all recommend some kind of visual aid to help you. The same applies for DTD development, but each expert has his or her own set of symbols. Some prefer to model using the blocks familiar from flow diagrams, as shown in Figure 14.5.
An alternative is the somewhat sparser representation form shown in Figure 14.6.
Note that both types of modeling graphics try to represent the sequence and OR models by using different kinds of connecting lines between the objects (diagonal for an OR choice, straight lines for a simple relationship, and rectangular connections for sequences). This type of modeling graphics is also incorporated in the top-of-the-line SGML DTD modeling package, Microstars NEAR & FAR, an example of which is shown in Figure 14.7.
It is difficult to think of a better way of modeling DTDs visually than these kinds of models (different is easy; better is hard), especially in a software package where you can expand and collapse branches of the DTD tree as you work on them. However, as the DTD gets larger and larger, it becomes harder and harder to maintain a sensible overview. You shouldnt forget that these are primarily SGML tools where people are mostly working on a different scale than is probably useful in XML. Where an XML application might need a few tens of elements and a couple hundred lines in a DTD, SGML applications routinely think in terms of several hun-dred elements and several thousand lines of declarations in a DTD. It isnt only the number of elements that makes the DTD bulky, though. Often, elements that have a presentational function (such as emphasized text) will be reused in almost every element. When you expand these models, as you can see from Figure 14.8, unless you start finding other ways to manage DTDs of this scale or complexity, even a well-designed visual presentation can become too cluttered for it to be of much use.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |