• Embed Doc
  • Readcast
  • Collections
  • CommentGo Back
Download
 
Exploring the XHTML DTD
Choosing Your DTD
XHTML 1.0 provides three DTDs that describe different sets of XHTML elementsand reflect the three choices provided in HTML 4.0: strict, transitional, and frameset. The probably theone that the W3C would like to see developers adhere to, but
transitional 
DTDs reflect the reality of HTML usage much more accurately. Appendix A lists the in the three different DTDs, along with notesregarding attributes. To identify the DTD for a given document, you must use a DOCTYPE declaration inthe prologue of your document. The XHTML 1.0 Recommendation provides three options, one for eachDTD. They look much like their HTML 4.01 predecessors, although their names are slightly different andthe HTML root element is now html. For the strict DTD, this HTML 4.01 declaration:
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
 becomes this XHTML 1.0 declaration:
<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
For the transitional DTD, this HTML 4.01 declaration:
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
 becomes this XHTML 1.0 declaration:
<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
And for the frameset DTD, this HTML 4.01 declaration:
<!DOCTYPE HTMLPUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN""http://www.w3.org/TR/html4/frameset.dtd">
 becomes this XHTML 1.0 declaration:
<!DOCTYPE htmlPUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Whichever declaration you choose, it must appear after the XML declaration (if there is one) and beforethe root element of the document. If your document passes through a validating parser, it checks your document to make sure that its contents conform to the rules laid out in the DTD.
Caution
The XHTML 1.0 Recommendation doesn't say anything about using another XML feature, theinternal subset of the DOCTYPE declaration. While its use isn't prohibited, you should avoid using it withXHTML documents.
 
 Starting Out 
All three DTDs follow roughly the same layout, with a few sections more or less dependingon the particular DTD you read. The first few sections of a DTD are often the most frustrating (they often put people off) because they lay groundwork for later declarations rather than make concrete declarations.Reading somewhat abstract collections of declarations outside of their context for page after page may notfeel rewarding, but it's important to understand these preliminaries in order to make sense of the concretedeclarations.
Tip
While these preliminaries are important in XHTML 1.0, they will become even more important whenXHTML is modularized in XHTML 1.1. Then you may need to choose which modules are used indocuments. Understanding how these pieces fit together is critical as the specification is broken intosmaller pieces.
Including character entities
After some introductory comments, the three XHTML DTDs all start byreferencing the entity sets – 
character mnemonic entities
 – supported by HTML: Latin-1, Symbols, andSpecial. Because these entity sets are stored in separate files, the DTDs can reference them easily withoutrequiring a special set for each DTD. (It also means that other XML applications can reference theXHTML entity sets easily without needing to incorporate the entire DTD.) The declaration for the Latin-1set, immediately followed by a reference including the material referenced by the declaration, looks like:
<!ENTITY % HTMLlat1 PUBLIC"-//W3C//ENTITIES Latin 1 for XHTML//EN""xhtml-lat1.ent">%HTMLlat1;
The entity declaration creates a parameter entity named HTMLlat1. HTMLlat1 references a set of declarations using two different identifiers, including a public identifier (-//W3C//ENTITIES Latin 1 for XHTML//EN) that applications can use if they already know what these entities are and don't want toretrieve information from the URL. Applications that don't understand the public identifier, like mostXML processors, can use the URL to retrieve the full set of declarations. Either way, documents that usethe XHTML DTDs may use the full set of entities.
Note
The URLs for the entity set locations are given as local URLs. If you want to reference these sets inyour own XML declarations, use the full form: http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent. Youalso may want to create a local copy — not all users of your XML DTDs may have access to the Internetor the W3C site. The copyright statement at the top of the DTD makes it clear that this kind of usage isacceptable.
Imported names
This declaration, for instance, creates the Character parameter entity; meanwhile, thecomment tells developers that attributes declared using this parameter entity must contain a singlecharacter as defined in ISO 10646.
Note
Appendix E of the XHTML 1.0 specification mostly omits the specs listed in square brackets, butthey are available at http://www.w3.org/TR/xhtml1/#refs. If you need to look up the RFCs, seehttp://www.rfceditor.org. For more on ISO 10646, see the XML 1.0 references athttp://www.w3.org/TR/REC-xml#secexisting- stds. Many of the types are defined more simply, withoutreferring to outside specifications. The Number entity, for instance, is described as "one or more digits."The Shape entity doesn't have a description, but its declaration limits it to a small set of well-known types:<!ENTITY % Shape "(rect|circle|poly|default)"> The transitional and frameset DTDs include twoadditional entities, ImgAlign and Color, which support formatting properties left out of the strict DTD.These entities are declared in a slightly different style, with their descriptive comments preceding thedeclaration rather than following it. These DTDs also provide a list of commonly supported colors incomments, although they aren't formally a part of the DTD that an XML parser understands.
of 00

Leave a Comment

You must be to leave a comment.
Submit
Characters: ...
You must be to leave a comment.
Submit
Characters: ...