So far we have seen that W3C XML Schema treats global attributes and
elements alike, requiring both types to be explicitly
namespace-qualified to be global. Although this approach makes
sense--there's little reason to treat elements and attributes
differently--it's different from the approach the
Namespaces in XML Recommendation took. Global
attributes turn out to be a rather unusual, though useful, case.
<book id="b0836217462" xmlns="http://dyomedea.com/ns/library"/>
or:
<lib:book id="b0836217462"
xmlns:lib="http://dyomedea.com/ns/library"/>
Very few would use qualified attributes, such as:
<lib:book lib:id="b0836217462"
xmlns:lib="http://dyomedea.com/ns/library"/>
Also, very few would use that or its equivalent if we use a default
namespace for the element that doesn't apply to the
attribute:
<book lib:id="b0836217462" xmlns="http://dyomedea.com/ns/library"
xmlns:lib="http://dyomedea.com/ns/library"/>
Unfortunately, since the W3C XML Schema requires that all the global
attributes be qualified, this means that global attributes
can't be used for those unqualified attributes that
are used most of the time in XML vocabularies, and that our
unqualified id attribute cannot be declared as
global. In practice, this means that most of the time we will just
define local attributes within the element or complex type
definitions. When we want to define unqualified attributes that may
be reused in different elements, we will either define them in a
specific schema without a target namespace, which will be imported
(but there is risk of collision if we mix several schemas for
different target namespaces following this policy), or
"hide" those attributes inside of
attribute groups, such as:
<xs:attributeGroup name="id">
<xs:attribute name="id" form="unqualified" type="xs:ID"/>
</xs:attributeGroup>
 |  |  |
10.3. To Qualify Or Not to Qualify? |  | 10.5. Namespaces and XPath Expressions |