W3C home > Mailing lists > Public > xmlschema-dev@w3.org > July 2004

Re: Qualified attributes and attribute references in schemas

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 21 Jul 2004 22:52:31 +0100
Message-ID: <466120812.20040721225231@jenitennison.com>
To: Adam van den Hoven <avandenhoven@cucbc.com>
Cc: XML Schema Development <xmlschema-dev@w3.org>

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" />

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.


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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:22 UTC