W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Re: Integrating XLink attributes into XML Schema

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 15 Mar 2002 10:15:22 +0000
Message-ID: <17179867535.20020315101522@jenitennison.com>
To: "Snow, Corey" <CSNOW@ddpwa.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Corey,

> How can I best allow Xlink attributes such as xlink:type and
> xlink:href to be added to a set of elements, and how can I require
> them to be part of a given element? For the first question, I'd like
> to be able to allow any attribute from the xlink namespace (In the
> future I'd like to support more complex links allowed by Xlink), and
> for the second, I'd like to be able to require the "xlink:type" and
> "xlink:href" attributes for a simple link-only element, to allow for
> an analogue of the HTML <A> element.

To include attributes or elements from another namespace, first you
have to import that namespace, preferably pointing to a schema for
that namespace:

<xs:import namespace="http://www.w3.org/1999/xlink"
           schemaLocation="xlink.xsd" />

Then you can refer to elements, attributes, types, groups and
attribute groups that are declared globally within that namespace just
as you can to ones in your own namespace.

To allow any attribute from the XLink namespace, you can use the
xs:anyAttribute wildcard:

  <xs:anyAttribute namespace="http://www.w3.org/1999/xlink" />

To specify specific attributes, assuming that the XLink namespace is
associated with the prefix 'xlink' within your schema, you can refer
to them as normal:

  <xs:attribute ref="xlink:type" use="required" fixed="simple" />
  <xs:attribute ref="xlink:href" use="required" />

For more complex patterns of use, for example where you restrict an
xlink:type attribute to only allow certain values on a particular
element, you need to create an adapter schema in the XLink namespace
that includes or redefines the normal XLink schema and defines
attribute groups in which the changes have been made, and then import
that schema and use those attribute groups.
  
> I've been looking, but there seems to be no schema for XLink in
> existance. So I'm considering rolling up my own schema for the Xlink
> namespace and using that. I wanted to know if there's a better/more
> standard way of doing this.

I don't think that the XLink people have put together an official XML
Schema, but there's one available that's used in XForms, which perhaps
you could adapt. See
http://www.w3.org/TR/xforms/sliceA.html#schema-xlink.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Friday, 15 March 2002 05:15:24 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:30 GMT