Re: Qualified attributes and attribute references in schemas

Hi Adam,

> As far as I can read in Eric Meyer's book the form should follow the
> default set in the root xs:schema element.

That's correct: the default for the "form" should follow the default
set on the <xs:schema> element. *However*, "form" only applies to
locally declared elements and attributes. If you declare an element or
attribute at the top level of your schema (as you have with foo), then
it is always in the target namespace for the schema. Attributes that
have a namespace must be qualified within the instance document, hence
you must refer to the attribute as 'b:foo' rather than just 'foo'.

If you want to made the foo attribute reusable, declare it within an
attribute group:

<xs:attributeGroup name="foo">
  <xs:attribute name="foo" type="xs:string" />
</xs:attributeGroup>

and then refer to it with:

  <xs:attributeGroup ref="b:foo" />

This way, the declaration is local, and the form determines whether or
not the attribute is in the target namespace of the schema or not.
With attributeFormDefault set to "unqualified" (the default) and no
overriding form attribute on the <xs:attribute> declaration, the
attribute will be in no namespace.
  
Cheers,

Jeni

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

Received on Wednesday, 21 July 2004 17:52:39 UTC