XML Tutorials
  Home arrow XML Tutorials arrow Page 3 - 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) - Creating an XML Prolog


    (Page 3 of 4 )

     

    A Prolog is the first thing in your XML document, and it is the first thing that will get processed. It contains five parts, some of which are optional. These parts are the declaration, the DOCTYPE declaration, instructions for the processor, white space, and comments. 

    XML Declaration 

    We have gone over this portion many times, so I will not bother to cover it again here. All you need to know now is that it is a part of the XML Prolog. 

    DOCTYPE 

    The DOCTYPE declaration tells the processor where to find your DTD. It is not truly XML, and is therefore written using SGML syntax. Here is an example of how you write the DOCTYPE: <!DOCTYPE albums SYSTEM “albums.dtd”> 

    This is a breakdown of how the above example works. !DOCTYPE signifies the beginning of a DOCTYPE declaration. Albums is the name of the DTD that we are using. SYSTEM “albums.dtd” is a way of telling the processor to look for a file called “albums.dtd.” 

    There are more ways to call a DTD file. In our above example, we are using a URI or a Uniform Resource Identifier. These are similar to URLs and truthfully, a URL is a form of a URI. The way we set up our reference to the DTD file via a URI above, means that the file “albums.dtd” is located in the same folder as our XML file. If your DTD file were located outside of the folders of your XML file, you would simply point to the URL where the DTD is located, such as http://www.mywebsite.com/file/albums.dtd

    Commenting 

    You should be familiar with the concept of commenting. It is the process of leaving notes/comments in your programs for other programmers or yourself. The computers and processors cannot see these comments and ignore them. Here is how you would write a comment in your file:

    <! – I am leaving a comment -- > 

    You must never leave a comment inside of an element and always make certain that you do not write a hyphen or double hyphen inside of the comment text, as it will confuse the processor. Here is what I mean: 

    <! – Hi – How are you? --> 

    When the processor sees the double hyphen after the word “Hi,” it will think that that is the end of the comment and treat the rest as normal syntax, causing errors. 

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek