Home arrow XML arrow Page 6 - Introduction To XML

The Best Of Both The Worlds - XML

It's a fact of life that XML, which stands for eXtensible Markup Language, is invading our lives more and more as programmers, and I feel this is a good thing. The reason being XML has the ability to cross all sorts of boundaries, and probably the only chance we have to obtain a truly independent, cross-platform data transfer format.

  1. Introduction To XML
  2. Preparing Yourself For The Future!
  3. The Name Says It All…..EXtensible:
  4. Proof Is In The Output
  5. Starting From The Roots of XML…
  6. The Best Of Both The Worlds
  7. The Potential Of XML
  8. XML Parser
By: Gayathri Gokul
Rating: starstarstarstarstar / 44
August 28, 2003

print this article


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 EMPLOYEE(emp_id, emp_lname, emp_fname, phone, address, zip)>
<!ELEMENT emp_id (CDATA)>
<!ELEMENT emp_lname(CDATA)>
<!ELEMENT emp_fname(CDATA)>
<!ELEMENT address (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”/>
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”/>
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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Google Docs and Xpath Data Functions
- Flex Array Collection Sort and Filtering
- The Flex Tree Control
- Flex List Controls
- Working with Flex and Datagrids
- 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...

Developer Shed Affiliates


Dev Shed Tutorial Topics: