In our example, the element name appears both
within author and character
with the same datatype. We may want to define the element
name with different content models in
author and character, as in
this instance document:
<?xml version="1.0"?>
<library>
<book id="b0836217462" available="true">
<isbn>
0836217462
</isbn>
<title lang="en">
Being a Dog Is a Full-Time Job
</title>
<author id="CMS">
<name>
<first>
Charles
</first>
<middle>
M.
</middle>
<last>
Schulz
</last>
</name>
<born>
1922-11-26
</born>
<dead>
2000-02-12
</dead>
</author>
<character id="Snoopy">
<name>
Snoopy
</name>
<born>
1950-10-04
</born>
<qualification>
extroverted beagle
</qualification>
</character>
</book>
</library>
Since we can define only one global element named
name, we need to define at least one of the
name elements locally under its parent.
The W3C Schema for XML Schema gives several examples of elements
having different types depending on their location. We will see this
used in the next section in our Russian doll schema: global
definitions of elements have a different type in the schema for
schema than local definitions or references, even though they use the
same element name (xs:element).