[
Lists Home |
Date Index |
Thread Index
]
- From: "Arnold, Curt" <Curt.Arnold@hyprotech.com>
- To: "'Roger L. Costello'" <costello@mitre.org>
- Date: Wed, 13 Sep 2000 12:31:55 -0600
The big difference is that by declaring an element as a top-level element, it can be used in other contexts, either as a top-level element in an instance or imported into schemas for other namespaces.
For example,
<b xmlns="http://www.example.org/namespace/b"
xmlns:a="http://www.example.org/namespace/a">
<a:bar>foo</a:bar>
</b>
is legal for your first fragment, but not for your second. In the first example, your element has global (better namespace) scope. In the second, it has local scope. If you search the XML Schema
Part 1 document for "scope", you will see a whole lot of text on the distinctions.
When elements are defined in the scope of a complex type, they are reachable only within that complex type.
From Part 1, Section 2.5:
Locally scoped attribute and element declarations are special with regard to symbol spaces. Every complex type definition defines its own local attribute and element declaration symbol spaces, where
these symbol spaces are distinct from each other and from any of the other symbol spaces.
This statement makes:
<element name="foo">
<complexType>
<element name="bar" type="string"/>
<element name="bar" type="string"/>
</complexType>
</element>
illegal (regardless of the value of type) since you have duplicate declarations of the same element name within the same symbol space. Though it is concievable that you could have sub-symbol spaces
within a complex type (a symbol space for each group, for example) and intra-complex type references to locally-scoped elements, I can't see that as being justified at this point.
|