XML
  Home arrow XML arrow Page 5 - 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 - 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:

    </xsd:schema>

    The whole file should now look like this:

    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="
    http://www.w3.org/2001/XMLSchema">
    <xsd:element name="news">
      <xsd:complexType>
      <xsd:sequence maxOccurs="unbounded">
        <xsd:element ref="article"/>
      </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
    <xsd:element name="article">
      <xsd:complexType>
      <xsd:sequence maxOccurs="1" minOccurs="1">
        <xsd:element ref="headline" />
        <xsd:element ref="story" />
      </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
    <xsd:element name="headline" type="xsd:string" />
    <xsd:element name="story" type="xsd:string" />
    </xsd:schema>

    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.

    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