Re: XML Schema Question

I think I understand Helen's confusion, as at least one other reader of 
the schemas draft has asked me about the same point.

Declaring a global element does NOT directly allow that element to appear 
in arbitrary points in the validated XML instance document.  Except when 
used as the root element (see Henry's note), global elements are available 
for reference when building content models.  Only the global elements you 
actually reference from a content model (or allow through use of 
wildcards) can appear in valid content. 

        <xsd:element name="a" .... />
        <xsd:element name="b" .... />
        <xsd:element name="c" .... />

        <xsd:element name="x">
                <xsd:complexType> 
                        <xsd:sequence>
                                <xsd:element ref="b"/>
                                <xsd:element ref="c"/>
                        </xsd:sequence>
                </xsd:complexType> 
        </xsd:element name="x">

The global elements named "b" and "c" must occur as children of "x" in the 
instance document; global element "a" is not legal within "x".  Depending 
how the processor is invoked, any of "a", "b", "c" or "x" might be usable 
as the root of the validation (which might mean as the root of the whole 
document, or it might mean that you are validating only part of the 
document.)

I think the confusion probably arises because readers see the term 
"global" and presume it to mean "anywhere in the instance document".  In 
fact, it means "available for use in any content model in the schema".  By 
contrast, "local" elements can only be used in the content model of the 
corresponding (scoping) complex type. Another way to think about this is 
that global element declarations in schemas give you the same capabilities 
as the element type declarations in XML 1.0 DTDs.  Local declarations are 
an enhancement in schemas, allowing  the same name to be used for 
different purposes according to context.  If you were doing a straight 
conversion from a DTD to a schema, most likely all the resulting element 
declarations would be global. 

I hope this clarifies the use and significance of global elements.   Thank 
you.

------------------------------------------------------------------------
Noah Mendelsohn                                    Voice: 1-617-693-4036
Lotus Development Corp.                            Fax: 1-617-693-8676
One Rogers Street
Cambridge, MA 02142
------------------------------------------------------------------------

Received on Friday, 29 September 2000 17:22:33 UTC