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

Re: key/keyref and default attributes

From: Jeni Tennison <jeni@jenitennison.com>
Date: Tue, 27 May 2003 17:03:22 +0100
Message-ID: <126430597095.20030527170322@jenitennison.com>
To: Alison Meynert <AlisonM@schemasoft.com>
CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>

Hi Alison,

> Can an attribute with a specified default be a keyref? When I try to
> validate the following example instance document with XML Spy, I get
> this error message:
>
> Undefined values for keyref identity constraint
> 'patternForegroundColorRef' - the values referred to in the field
> selector must match an existing unique/key value.
>
> I take this to mean that if I specify an attribute as a keyref, it
> is required in the instance document?

The XML Schema spec specifically says:

 "NOTE: The use of [schema normalized value] in the definition of key
  sequence above means that default or fixed value constraints may
  play a part in key sequences."

It's absolutely fine to specify a defaulted attribute as a keyref.
Your document is valid according to both Xerces and MSXML. The error
that you're getting in XML Spy is due to a bug in its schema
validator -- I suggest you send a bug report and start using Xerces or
MSXML as your schema validator as they are generally a lot more
conformant.

If you have to stick to XML Spy, note that the other constraints that
you've used in your schema mean that you don't actually need the
keyref for validation. You have to have eight colors in your
colorTable; they have to have different values for their index
attributes due to the colorKey; and those values of the index
attributes have to be the integers between 0 and 7. Therefore the fact
that the foregroundColor and backgroundColor attributes have to have
integer values between 0 and 7 automatically constrains them to
pointing to one of the colors.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Tuesday, 27 May 2003 12:03:43 GMT

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