XML Tutorials
  Home arrow XML Tutorials arrow Page 2 - Validation with Document Type Definiti...
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML TUTORIALS

Validation with Document Type Definitions (DTDs)
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 2
    2009-02-25

    Table of Contents:
  • Validation with Document Type Definitions (DTDs)
  • Getting to Know DTDs
  • Creating an XML Prolog
  • Whitespace

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Validation with Document Type Definitions (DTDs) - Getting to Know DTDs


    (Page 2 of 4 )

     

    Now that we know what document descriptions are and whether or not we should use one, we can begin learning about the first type, document type definitions or DTDs. 

    Before we begin however, it is important to know one thing: if you do decide to use a DTD to validate your XML, you must make sure your document is valid; certain processors will cease to operate if they encounter invalid documents. So think carefully before using them. 

    On the flip side, DTDs can help maintain structure and integrity within your data. A DTD gives definition to the elements and attributes that make up your document. Think of it as a form of grammar. The reason  DTDs are optional in XML is because XML itself (when written properly) is well-formed, and processors can sometimes get the gist of what rules you are implying. 

    Below is a list of some terms you should know when dealing with DTDs. 

    Document Type Declaration (DOCTYPE) – This declaration comes after the XML declaration we learned before, and tells the processor where the DTD file is located.

    It can look like this: <!DOCTYPE Root-Element SYSTEM “nameofthefile.dtd”> 

    Element Type Declaration – Used to give definition to an element type. An example would be: <!ELEMENT Name(#PCDATA)> 

    Attribute-list Declaration – Used to give definition to a datatype, default value, and name for each attribute associated with an element. An example of this would be: <!ATTLIST Element-Name Name Datatype Default> 

    Entity Declaration – Used to give definition to data referenced by an entity. An example of this would be: <!ENTITY Entity-Name “text”> . We will discuss entities more in a later article. 

    Notation Declaration – Gives association to a notation name with data that is used to find an interpreter program that is typically external, when XML processors cannot do so themselves. An example would be <!NOTATION NameSystem “externalID”> 

    XML Declaration – Informs the processor as to which version of XML you are using. An example would be <?xml version=”1.0” encoding=”UTF-8”?> 

    More XML Tutorials Articles
    More By James Payne


       · I think that someone needs to proof-read this article - none of the examples seem to...
       · I agree - I think there are some problems with this series of articles. I can spot a...
     

    XML TUTORIALS ARTICLES

    - Validation with Document Type Definitions (D...
    - Creating a Well-Formed XML Document
    - Creating XML Taxonomies
    - Getting to Know XML
    - A Friendly Approach to XML
    - Creating RSS 2.0 Feeds
    - Using Modules in Your RSS Feed
    - RSS 2.0
    - Querying XML: Use Cases
    - Joins and Query Use with XML
    - Solving Problems by Querying XML
    - Performing Set Operations When Querying XML
    - Querying XML
    - Handling Data for Ajax with JSON
    - Handling XML Data for Ajax





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek