A DTD for Products

First, you'll look at reading data from XML files using Xerces. Reading in the product list for the BFG site serves as a good example. To see how this works, you'll begin by writing a DTD to represent products in your shopping cart application so that you can add new books to the database from an XML file (see Listing 14.1).

Listing 14.1. Product.dtd
 <?xml version='1.0' encoding='UTF-8' ?> <!ELEMENT File (Product)*> <!ELEMENT Product (Title, Authors, Price, Pubdate, Description, Categories)> <!ATTLIST Product ISBN CDATA #REQUIRED > <!ELEMENT Title (#PCDATA)> <!ELEMENT Authors (Author)+> <!ELEMENT Author (#PCDATA)> <!ELEMENT Price (#PCDATA)> <!ELEMENT Pubdate (#PCDATA)> <!ELEMENT Description (#PCDATA)> <!ELEMENT Categories ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL 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.