Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

XML DTDs : Page 3

Valid XML documents follow a set of rules defined in a associated DTD. This Document Type Definition defines elements, attributes, and relationships between elements.


advertisement

Internal DTDs
You can insert DTD data within your doctype declaration. This type of DTD is used only by the one specific XML document that contains it.

This is a very simple example of DTD data within the doctype declaration. Click on any line of the code to learn what it does.

<!DOCTYPE books [
   <!ELEMENT title (#PCDATA)>
   <!ELEMENT author (#PCDATA)>
   <!ENTITY copyright "Copyright 1999, Flying Toys Inc., all rights reserved.">
]>



External DTDs
DTDs are stored as ascii text files with the extenstion .dtd. Each file begins with a DOCTYPE definition and includes a seres of element definitions, attribute lists, entity defintions and notation definitions. Here's an example; this might be the DTD for a set of documents about books. Click on any line for more information about it:

<!--This defines a listing of books-->
<!DOCTYPE booklist [
<!ELEMENT booklist (title, author)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>

<!ATTLIST title (paper|cloth|hard) "paper">
   <!ENTITY copyright "Copyright 1999, Flying Toys Inc., all rights reserved.">
]>

DTDs can be much more complex than this example—and they typically are—but this gives you a sense of what they can do. It's just a matter of structuring your data and figuring out the "parts" of your content.





Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date