Home arrow XML arrow Page 5 - 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 - The Complete File
(Page 5 of 7 )

Anyway, as this is all that our extremely simple schema document needs in order to validate our extremely simple XML document, we can end the schema with the closing schema element:


The whole file should now look like this:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="
<xsd:element name="news">
  <xsd:sequence maxOccurs="unbounded">
    <xsd:element ref="article"/>
<xsd:element name="article">
  <xsd:sequence maxOccurs="1" minOccurs="1">
    <xsd:element ref="headline" />
    <xsd:element ref="story" />
<xsd:element name="headline" type="xsd:string" />
<xsd:element name="story" type="xsd:string" />

Save the document with an .xsd prefix. As schema documents are just well-formed XML documents, you can also save it with an .xml prefix and load it up in a browser. If there are any typos or syntax errors in the schema, it wonít load. You need to use an XML compliant browser of course; for the purpose of this article, Iíve used MS IE6.

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