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

Re: Attribute Fixed and Prohibited

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 27 Mar 2002 13:23:48 +0000
Message-ID: <130400635723.20020327132348@jenitennison.com>
To: Joey <lpjcoyle@ihc.com>
CC: xmlschema-dev@w3.org
Hi Joey,

> I want an attribute to have a fixed value that is available to the
> schema processor, but not allow the attribute in instances. Is the
> following valid, and does it do what I want.
> <xs:attribute name="domain" type="xs:positiveInteger" use="prohibited" 
> fixed="123"/>

The use="prohibited" attribute is a way of removing attribute uses
from the set of attributes for a complex type when you derive by
restriction. It bans the attribute from appearing in the instance, but
it also means that the attribute isn't present in the PSVI, so you
won't have access to the fixed value at all.

I don't think that there is a way of doing what you describe. I guess
that you could say that the attribute is optional (the default), with
a fixed value:

  <xs:attribute name="domain" type="xs:positiveInteger" fixed="123"/>

And then have a Schematron rule that tests whether it's actually

  <sch:report test="@domain">
    The domain attribute should not be present.

This will only work if you're using Schematron with XSLT 1.0; come
XSLT 2.0, XSLT will work over the PSVI, so won't be able to tell the
difference between an attribute that's actually present in the
document and one that's been fixed or defaulted in the schema.

Out of interest, why do you want to do this, and how are you intending
that the fixed attribute be used by applications? If you want to
provide a kind of "annotation" about an element, I suggest that you
use xs:appinfo instead:


Applications with access to the PSVI should get access to the content
of xs:appinfo in order to get this value; since it's not declared as
an attribute, there's no risk of it appearing in the instance



Jeni Tennison
Received on Wednesday, 27 March 2002 08:23:49 UTC

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