Home arrow XML arrow An Introduction to XML Schemas

An Introduction to XML Schemas

XML Schemas help you control what elements appear in your XML documents. Similar to Document Type Definitions, they offer distinct advantages over the older syntax. Dan Wellman provides a basic overview, with examples to get you started working on your own.

Author Info:
By: Dan Wellman
Rating: 5 stars5 stars5 stars5 stars5 stars / 13
November 03, 2004
  1. · An Introduction to XML Schemas
  2. · Choose Your Schema
  3. · Element Declarations
  4. · Definitions and Elements
  5. · The Complete File
  6. · Validating a Document
  7. · A Few Final Tips

print this article

An Introduction to XML Schemas
(Page 1 of 7 )

Support file for this article available here.

XML Schemas are an area of XML syntax that is very similar in some ways to DTDs or Document Type Definitions; they govern, among other things, which elements should appear, and in which order, in your XML documents. They havenít been around as long as DTDs; the XML Schema specification didnít become an official W3C recommendation until May 2001, whereas DTDs were originally invented to work with SGML, or Standard General Markup Language (the metalanguage that most other markup languages are subsets of.)

The main differences between DTDs and Schemas are that XML Schemas are written in XML syntax and DTDs are not, and that Schemas are always external documents whereas DTDs can be internal or external. Aside from these two things, their purpose and function are fairly similar. A lot of people say that one of the main benefits of Schemas is that they are written in XML, and while it is true that you donít have to learn a new language (assuming you already know a bit about XML), DTD language itself is not that difficult to master. 

So why use a Schema instead of a DTD? The XML Schema specification offers everything a DTD can do; this is necessary so that existing DTDs can be rewritten as Schemas, but they also offer more in addition to that--they have a wider range of data types than DTDs, you can create custom data types, and Schemas are namespace aware whereas DTDs are not. DTDs are useful when dealing with elements containing text, but schemas offer far more control when dealing with documents whose elements contain letters and numbers.  

Additionally, DTDs and Schemas are basically formatting structures, and one of the reasons for using XML is to separate data from formatting instructions. Only ever being able to use Schemas externally goes a long way to ensuring that this separation is maintained. Ultimately, most XML authoring software offers a DTD-to-Schema Conversion, but I havenít seen any that want to do it the other way round for you. 

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials