Home arrow XML arrow Page 4 - Doing More With XML Schemas (part 2)

Big Brother Is Watching... - XML

In this second part, find out how to derive new element types by constraining existing ones, control access to your schema definitions, and redefine externally-provided schemas in place.

TABLE OF CONTENTS:
  1. Doing More With XML Schemas (part 2)
  2. Feeling The Force
  3. The Next Level
  4. Big Brother Is Watching...
  5. Speaking In The Abstract
  6. Going Local
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 5
January 23, 2003

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement
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
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

XML ARTICLES

- Google Docs and Xpath Data Functions
- 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...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: