Using Document Type Definitions with URLs

The previous example just listed the name of an external DTD in the <!DOCTYPE> element. However, if the DTD is not in the same directory on the Web site as the document itself, you can specify a Uniform Resource Indentifier (URI) (which is currently implemented as URLs for today's XML processors) for the DTD, like this:

 <?xml version = "1.0" standalone="no"?>  <!DOCTYPE DOCUMENT SYSTEM   "http://www.starpowder.com/dtd/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> 

This is also very useful, of course, if you're using someone else's DTD. In fact, there's a special way of using DTDs intended for public distribution.



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