Using Document Type Definitions with URLs

The previous example just listed the name of an external DTD in the <!DOCTYPE> element, but if the DTD is not in the same directory on the Web site as the document itself, you can specify a 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/order.dtd"> <DOCUMENT> <CUSTOMER> <NAME> <LAST_NAME>Smith</LAST_NAME> <FIRST_NAME>Sam</FIRST_NAME> </NAME> <DATE>October 15, 2001</DATE> <ORDERS> <ITEM> <PRODUCT>Tomatoes</PRODUCT> <NUMBER>8</NUMBER> <PRICE>$1.25</PRICE> </ITEM> <ITEM> <PRODUCT>Oranges</PRODUCT> <NUMBER>24</NUMBER> <PRICE>$4.98</PRICE> </ITEM> . . . <ITEM> <PRODUCT>Asparagus</PRODUCT> ...

Get Inside XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.