XML
  Home arrow XML arrow Page 8 - Understanding XML Schema
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
Google.com  
XML

Understanding XML Schema
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 3
    2001-10-15


    Table of Contents:
  • Understanding XML Schema
  • The Next Generation
  • An Evening At The Moulin Rouge
  • Simple Simon
  • A Complex Web
  • Nesting Season
  • Battle Of The Sexes
  • Dealing With The Ref
  • Different Flavours
  • When In Rome...
  • Test Drive
  • The Next Step

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Understanding XML Schema - Dealing With The Ref
    ( Page 8 of 12 )

    Now, while it's certainly possible to build a schema in the manner just described, with the schema definition following the structure of the document instance, such a schema can prove difficult to maintain and read with long and complex documents. Consequently, the XML Schema specification allows for an alternative method of schema construction, whereby elements and attributes can be defined separately and then referenced wherever required.

    An example might help to make this clearer - consider the following revision of the previous example:

    <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="title" type="xsd:string"/> <xsd:element name="release_date" type="xsd:date"/> <xsd:element name="rating" type="xsd:integer"/> <xsd:attribute name="genre" type="xsd:string"/> <xsd:attribute name="sex" type="xsd:string"/> <xsd:element name="person"> <xsd:complexType> <xsd:simpleContent> <xsd:restriction base="xsd:string"> <xsd:attribute ref="sex" /> </xsd:restriction> </xsd:simpleContent> </xsd:complexType> </xsd:element> <xsd:element name="cast"> <xsd:complexType> <xsd:sequence> <xsd:element ref="person" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> </xsd:element> <!-- it all comes together here --> <xsd:element name="movie"> <xsd:complexType> <xsd:sequence> <xsd:element ref="title"/> <xsd:element ref="cast"/> <xsd:element ref="release_date" maxOccurs="1" minOccurs="0"/> <xsd:element ref="rating"/> </xsd:sequence> <xsd:attribute ref="genre"/> </xsd:complexType> </xsd:element> </xsd:schema>
    In this form of construction, each element and attribute is defined separately and can be referenced by any other element definition via the "ref" attribute. This type of schema definition is much easier to read than the previous one.

     
     
    >>> More XML Articles          >>> More By Harish Kamath, (c) Melonfire
     

       

    XML ARTICLES

    - Flex Array Collection Sort and Filtering
    - The Flex Tree Control
    - Flex List Controls
    - Working with Flex and Datagrids
    - How to Set Up Podcasting and Vodcasting
    - Creating an RSS Reader Application
    - Building an RSS File
    - An Introduction to XUL Part 6
    - An Introduction to XUL Part 5
    - An Introduction to XUL Part 4
    - An Introduction to XUL Part 3
    - An Introduction to XUL Part 2
    - An Introduction to XUL Part 1
    - XML Matters: Practical XML Data Design and M...
    - Practical XML Data Design and Manipulation f...





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