XML
  Home arrow XML arrow An Introduction to XML Schemas
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
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

An Introduction to XML Schemas
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 12
    2004-11-03

    Table of Contents:
  • An Introduction to XML Schemas
  • Choose Your Schema
  • Element Declarations
  • Definitions and Elements
  • The Complete File
  • Validating a Document
  • A Few Final Tips

  • 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


    An Introduction to XML Schemas


    (Page 1 of 7 )

    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.


    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. 

    More XML Articles
    More By Dan Wellman


       · Hi,On page 3 of 7,...
       · Thanks for pointing that one out, a small error but one that will no doubt have...
     

    XML ARTICLES

    - 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
    - Simple Web Syndication with RSS 2.0
    - Java UI Design with an IDE







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