O'Reilly logo

XML and Java™ from scratch by Nicholas Chase

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

External DTDs

Before the DTD gets any bigger, let's go ahead and move it out to its own document, as we did with the style sheets. First, we'll create the DTD file itself and call it products.dtd. We'll save it in the same directory as products.xml. As shown in Listing 3.9, we're keeping the content the same, but this file doesn't include the <!DOCTYPE> declaration that was in the products.xml file.

Listing 3.9. Creating an External DTD
 0: <!ELEMENT products (vendor)+> 1: 2: <!ELEMENT vendor (vendor_name, advertisement?, product*)> 3: <!ATTLIST vendor webvendor CDATA #REQUIRED> 4: 5: <!ELEMENT vendor_name (#PCDATA)> 6: 7: <!ELEMENT advertisement (ad_sentence)+> 8: <!ELEMENT ad_sentence (#PCDATA | b | i | p )*> 9: <!ELEMENT b (#PCDATA)> 10:<!ELEMENT ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required