Public Document Type Definitions

When you have a DTD that's intended for public use, you use the PUBLIC keyword instead of SYSTEM in the <!DOCTYPE> document type declaration. To use the PUBLIC keyword, you must also create a formal public identifier (FPI), and there are specific rules for FPIs:

  • The first field in an FPI specifies the connection of the DTD to a formal standard. For DTDs that you're defining yourself, this field should be - . If a nonstandards body has approved the DTD, use + . For formal standards, this field is a reference to the standard itself (such as ISO/IEC 13449:2000 ).

  • The second field must hold the name of the group or person that is going to maintain or be responsible for the DTD. In this case, you should use a name that is unique and identifies your group easily (for example, W3C simply uses W3C ).

  • The third field must indicate the type of document that is described, preferably followed by a unique identifier of some kind (such as Version 1.0 ). This part should include a version number that you'll update.

  • The fourth field specifies the language your DTD uses. (For example, for English you use EN . Note that two-letter language specifiers allow only a maximum of 24 x 24 = 576 possible languages; expect to see three-letter language specifiers in the near future.)

  • Fields in an FPI must be separated by a double slash ( // ).

Here's how I can modify the previous example to include a public DTD, complete with its own FPI:

 <?xml version = "1.0" standalone="no"?>  <!DOCTYPE DOCUMENT PUBLIC "-//starpowder//Custom XML Version 1.0//EN"   "http://www.starpowder.com/steve/ch03_10.dtd">  <DOCUMENT>     <CUSTOMER>         <NAME>             <LAST_NAME>Smith</LAST_NAME>             <FIRST_NAME>Sam</FIRST_NAME>         </NAME>         <DATE>October 15, 2003</DATE>         <ORDERS>             <ITEM>                 <PRODUCT>Tomatoes</PRODUCT>                 <NUMBER>8</NUMBER>                 <PRICE>.25</PRICE>             </ITEM>             <ITEM>                 <PRODUCT>Oranges</PRODUCT>                 <NUMBER>24</NUMBER>                 <PRICE>.98</PRICE>             </ITEM>             .             .             .             <ITEM>                 <PRODUCT>Asparagus</PRODUCT>                 <NUMBER>12</NUMBER>                 <PRICE>.95</PRICE>             </ITEM>             <ITEM>                 <PRODUCT>Lettuce</PRODUCT>                 <NUMBER>6</NUMBER>                 <PRICE>.50</PRICE>             </ITEM>         </ORDERS>     </CUSTOMER> </DOCUMENT> 

Note the syntax of the <!DOCTYPE> element in this case: <!DOCTYPE rootname PUBLIC FPI URL > . Here's the external DTD, ch03_10.dtd, which is the same as in the previous example:

 <!ELEMENT DOCUMENT (CUSTOMER)*>  <!ELEMENT CUSTOMER (NAME,DATE,ORDERS)> <!ELEMENT NAME (LAST_NAME,FIRST_NAME)> <!ELEMENT LAST_NAME (#PCDATA)> <!ELEMENT FIRST_NAME (#PCDATA)> <!ELEMENT DATE (#PCDATA)> <!ELEMENT ORDERS (ITEM)*> <!ELEMENT ITEM (PRODUCT,NUMBER,PRICE)> <!ELEMENT PRODUCT (#PCDATA)> <!ELEMENT NUMBER (#PCDATA)> <!ELEMENT PRICE (#PCDATA)> 


Real World XML
Real World XML (2nd Edition)
ISBN: 0735712867
EAN: 2147483647
Year: 2005
Pages: 440
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net