HomeXML Page 2 - Doing More With XML Schemas (part 2)
Feeling The Force - 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.
In "The Phantom Menace", when Qui-Gon Jinn first meets Anakin Skywalker on an unscheduled stop at the Outer Rim world of Tatooine, he immediately realizes that there is something special about the boy: he is destined to be a Jedi.
Or is he?
"The Phantom Menace" and subsequent episodes certainly resolve that question conclusively - but what does that have to do with XML schemas?
Quite a lot, as you'll see shortly. First, though, let's quickly revisit a segment from the first part of this article, in which I defined a complex data type named "starWarsEntity",
Let's now extend things a little further, and derive one more datatype from the "Human" complex type - we'll call this one "Jedi", and make sure that it inherits all the characteristics of the "Human" type, together with one additional attribute. Here's the definition:
In case you're wondering - midi-chlorians are microscopic symbiotic creatures that swim around in the bloodstream of creatures in the Star Wars universe. In Star Wars lore, every Jedi possesses an unusually large number of these creatures, which are the reason they are so receptive to the Force; in "The Phantom Menace", Qui-Gon Jinn uses this midi-chlorian count to determine Anakin's eligibility for Jedi-hood.
What I just showed you was an example of deriving, by extension, one new type from another existing type, which is itself derived from a base type. This type of extensibility is what makes XML Schemas so powerful...and so easy to maintain.