Re: Wrapped around the axle: Refining and extending structures across namespaces

Hi Michael,

> 1. Am I correct to assume a substitution group can contain elements
> from multiple namespaces as your example using ns2 suggests?

Yes. That's one of the great powers of substitution groups. Imagine an
XHTML schema that defined a 'phrase' abstract element, with 'em' and
'strong' and so on being part of that substitution group. You could
add elements in your own namespace to that substitution group,
extending your XHTML documents with phrasal elements that suit your
domain.

> 2. I thought all elements in a substitution group had to be derived
> from a common type, which itself must be in a particular namespace.

That's right (although the type could be in no namespace) - the types
of the members of a substitution group must be valid derivations of
the type of the head of the substitution group.

> Presumably the effect of the element definitions in ns2 create
> *elements* in ns2, whose base content model is that of the *type* of
> the element in ns1 that is the head of the substitution group.

Yes. Element declarations always declare elements. The type of those
elements must be derived from the type of the element that's the head
of their substitution group. I deliberately didn't use a type
attribute on the abstract elements (DocumentExtension and
HeaderExtension) that I used, so that these elements had the type
xs:anyType, and therefore the extension elements could be of any type
(since all types are valid restrictions of xs:anyType).

> 3. What is the effect of elementFormDefault in the two schemas? For
> instance, if the head (say in ns1) defines some base content and
> uses a form default of qualifed, but the substitution element
> extending this (say in ns2) uses unqualified, does an instance using
> the the element from ns2 have both base and extended content
> unqualified, or the base stuff qualified and the extension stuff
> unqualified, or all qualified?

The elementFormDefault attribute defines whether elements that are
declared locally (in complex types or in model groups) are qualified
(in the target namespace) or unqualified (in no namespace) by default.

In fact, the elementFormDefault attribute has no effect when it comes
to the heads or members of substitution groups, because both the heads
and members of substitution groups *must* be global elements, declared
at the top level of the schema, and therefore in the target namespace.

> 4. Does the same apply to the use of xsi:type? For instance, can a
> type in ns2 extend a type in ns1 and be substituted for ns1 on an
> element allowing such substitution? I presume whatever your answer
> re form default above would apply equally to to this situation?

Yes, a type in ns2 can extend (or restrict) a type in ns1. Elements
of the ns1 type can then have xsi:type point to the type in ns2
(unless, of course, you've prevented this by using the block
attribute on the type definition or element declaration).

Form doesn't apply to types - form is purely about the namespace of
elements and attributes.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Thursday, 20 December 2001 11:07:58 UTC