Re: How to restrict the values of attributes in my own element declarations when they are defined in another namespace

On Wed, 2003-07-30 at 11:59, Geoff wrote:

> I am trying to find a way to restrict the value of an xlink:type
> attribute depending on the element in which it is used.

.../...

> Any suggestions on how to impose this kind of restriction would be
> gratefully received,

Since you are using two namespaces, you'll need to use two schemas (one
for each namespace) and any restriction to apply on components defined
for a namespace needs to be applied in the schema for this namespace.

In other word, to apply restrictions on attributes from the XLink
namespace, you need to define your own schema for this namespace and
import this schema instead of the usual schema for XLink.

Now, your schema can either include and/or redefine the usual schema for
XLink or be standalone and contain its own definitions (the schema for
XLink won't probably change in a near feature).

When you'll want to include xlink:type attributes with different
enumerations in your schema, you'll be in trouble if you want to use a
reference to the xlink:type attribute which definition will be unique. 

To workaround this, the easiest solution is to create an attribute group
(with a different name) in your schema for xlink for each case, for
instance:

<xs:attributeGroup name="simpleLink">
 <xs:attribute name="type">
  <xs:simpleType>
   <xs:restriction base="token">
    <xs:enumeration value="simple"/>
   </xs:restriction>
  </xs:simpleType>
 </xs:attribute>
</xs:attributeGroup>

In these groups, you may also include the other XLink attributes if that
makes your life easier.

Another option is to create complex types with these attributes and use
them in complex type derivations by extension but I tend to see this as
more complex.

Hope this helps.

Eric
-- 
Read me on XMLhack.
                                      http://xmlhack.com/author.php?id=8
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------

Received on Thursday, 31 July 2003 03:28:14 UTC