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

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

From: Eric van der Vlist <vdv@dyomedea.com>
Date: 31 Jul 2003 09:28:05 +0200
To: xmlschema-dev@w3.org
Message-Id: <1059636485.16662.396.camel@delleric>

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

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

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.

Read me on XMLhack.
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

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:02 UTC