XML
  Home arrow XML arrow Page 4 - 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 - Definitions and Elements


    (Page 4 of 7 )

    If you are creating a schema document for an XML document with many elements and child elements, you need to remember to define any simple elements directly after the complex definition that declares them. For example, if the <story> element contained child elements called <body> and <footer>, we would still define the simple element <headline> directly after the <article> complex definition. The simple definitions for <body> and <footer> would then come directly after the complex definition for the <story> element, which would follow the simple definition for <headline>. 

    In this example however, the <story> element does not have children.  Now, to define the datatype of the elements we’ve declared, you just add a type declaration to the simple element definitions, in this case using the built-in datatype ‘string’:

    <xsd:element name="headline" type="xsd:string" />
    <xsd:element name="story" type="xsd:string" />

    Wandering slightly from the task at hand here, you can constrain an element to having only certain values. If for example the news.xml document had an <author> element, with possible values of only particular names, you would use a restriction base and enumeration's to define the possible values:

    <xsd:simpleType name="author">
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="Fred"/>
        <xsd:enumeration value="Barney"/>
        <xsd:enumeration value="Wilma"/>
        <xsd:enumeration value="Betty"/>
      </xsd:restriction>
    </xsd:simpleType>

    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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek