XML
  Home arrow XML arrow Page 6 - Introduction To XML
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
VPS Hosting 
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

Introduction To XML
By: Gayathri Gokul
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 44
    2003-08-28

    Table of Contents:
  • Introduction To XML
  • Preparing Yourself For The Future!
  • The Name Says It All…..EXtensible:
  • Proof Is In The Output
  • Starting From The Roots of XML…
  • The Best Of Both The Worlds
  • The Potential Of XML
  • XML Parser

  • 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


    Introduction To XML - The Best Of Both The Worlds


    (Page 6 of 8 )

    We will discuss both DTDs and Schemas you can decide which to use. A DTD is a text file that defines the structure of an XML document, but DTDs isn’t XML – it is completely separate syntax.

    Let us look at a typical DTD – say you have Employees table in your database that had fields like emp_id, emp_lname, emp_fname, phone, address, zip. Then the XML document generated for this Employee from the database will look this below.
    <!ELEMENT DOCUMENT (EMPLOYEE+)>
    
    <!ELEMENT EMPLOYEE(emp_id, emp_lname, emp_fname, phone, address, zip)>
    <!ELEMENT emp_id (CDATA)>
    <!ELEMENT emp_lname(CDATA)>
    <!ELEMENT emp_fname(CDATA)>
    <!ELEMENT phone(CDATA)>
    <!ELEMENT address (CDATA)>
    <!ELEMENT zip (CDATA)>
    This is actually quite simple it states that this document comprises zero or more employee elements. The plus sign on the end of EMPLOYEE says one or more. Each EMPLOYEE element is made up of six other elements. And each of these sub-elements contains character data (CDATA).

    There are two real flaws with DTD:
    • They are not XML as such
    • You cannot specify data types such as integer, data and so on.

    Because of this Microsoft proposed Schemas to the W3C. If we converted the above DTD into a Schema it will look something like this:

    <Schema ID=”EMPLOYEE”>
    
    <ELEMENT name = “emp_id”/>
    <ELEMENT name = “emp_lname”/>
    <ELEMENT name = “emp_fname”/>
    <ELEMENT name = “phone”/>
    <ELEMENT name = “address”/>
    <ELEMENT name = “zip”/>
    </Schema>
    With the addition of data types display will look like below.
    <Schema ID=”EMPLOYEE”>
    
    <ELEMENT name = “emp_id” type = “string”/>
    <ELEMENT name = “emp_lname” type = “string”/>
    <ELEMENT name = “emp_fname” type = “string”/>
    <ELEMENT name = “phone” type = “string”/>
    <ELEMENT name = “address” type = “string”/>
    <ELEMENT name = “zip” type = “string”/>
    </Schema>
    Namespaces:
    One problem with XMl is you can give an element almost any name. Unfortunately this means there is good chance you’ll pick the same name as someone else. This is where namespaces come in, as namespaces uniquely identifies the schema to which elements belong. Namespaces are added to XML document by defining the xmlns attributes in the root tag, which requires Uniform resource Identifier (URI).

    More XML Articles
    More By Gayathri Gokul


     

       

    XML ARTICLES

    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway