Home arrow XML arrow Page 2 - 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 - Choose Your Schema
(Page 2 of 7 )

There are actually quite a few different Schema specifications to choose from, but for maximum compatibility and support, the W3C recommendation should be used. If youíre familiar with XML, youíll know that you donít always need to use a DTD or a Schema to make a well formed XML document, but if you want to share information with somebody else, itís best to use a Schema or DTD to make sure you are giving each other the correct data in the correct format. Additionally, if you are producing XML documents that contain a lot of data, itís good to have a Schema or DTD to validate the documents with to ensure consistency and validity.

The great thing about XML is that you can create your own mark-up tags. This is all well and good, but what if you give an element the same name that someone else has given an element in their own XML vocabulary? How do you create uniqueness between the two documents that transcends naming conventions? The answer is namespaces, which act as a unique identifier to schemas. This is achieved by targeting the namespace in your schema and using a prefix before your element declarations. 

The namespace used is part of the XML declaration at the beginning of your schema document. Because XML schema documents are essentially XML documents, they must begin with the XML declaration:

<?xml version=Ē1.0Ē?>

Directly after this needs to come the namespace declaration:

<xsd:schema xmlns:xsd=http://www.w3.org/2001/XMLSchema>

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