XML
  Home arrow XML arrow Page 4 - Doing More With XML Schemas (part 2)
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM developerWorks
 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

Doing More With XML Schemas (part 2)
By: Harish Kamath, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2003-01-23

    Table of Contents:
  • Doing More With XML Schemas (part 2)
  • Feeling The Force
  • The Next Level
  • Big Brother Is Watching...
  • Speaking In The Abstract
  • Going Local

  • 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

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Doing More With XML Schemas (part 2) - Big Brother Is Watching...


    (Page 4 of 6 )

    It's also possible to control whether or not schema designers can derive new datatypes from existing one, simply by specifying the level of extensibility allowed in the base definition. This is accomplished via the "final" attribute, which can accept any one of three values: "restriction", "extension" and "#all". Consider the following example, which illustrates:


    <xsd:complexType name="Human" final="#all"> <xsd:complexContent> <xsd:extension base="starWarsEntity"> <xsd:sequence> <xsd:element name="gender" type="xsd:string"/> </xsd:sequence> </xsd:extension> </xsd:complexContent> </xsd:complexType>


    In this case, I've specified that new types may *not* be derived from this type by extending or restricting it, via the "final" attribute. In order to verify that this works, try deriving a new type by extension and using that derived type in a document instance - your XML validator should display an error.

    This ability to control the extent to which a base type can be used for further type derivations is very important when you're creating layered schema definitions; it can provide schema authors with an easy, efficient way to restrict misuse or erroneous use of a type definition, especially in the case of schemas which are widely used by many different applications.

    You can specify a default "final" value for *all* the datatypes in a schema via the special "finalDefault" attribute, which must be included within the outermost <xsd:schema> element. In order to illustrate, consider the following code snippet, which allows derivation of new types from all existing definitions by restriction only.


    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" finalDefault="extension"> <!-- definitions --> </xsd:schema>

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


     

       

    XML ARTICLES

    - 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...
    - SimpleXML
    - XForms Basics, Part 3
    - XForms Basics, Part 2
    - XForms Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway