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

RE: Attribute Fixed and Prohibited

From: Andy Del Rio <adelrio@decadesystems.com>
Date: Fri, 29 Mar 2002 11:08:28 -0500
To: "Stanley Guan" <stanley.guan@oracle.com>, <xmlschema-dev@w3.org>
Message-ID: <PJEGLHABDMFKMBPDFGKAMEKECAAA.adelrio@decadesystems.com>
From http://www.w3.org/TR/xmlschema-0/

"Default values of both attributes and elements are declared using the
default attribute, although this attribute has a slightly different
consequence in each case. When an attribute is declared with a default
value, the value of the attribute is whatever value appears as the
attribute's value in an instance document; if the attribute does not appear
in the instance document, the schema processor provides the attribute with a
value equal to that of the default attribute. Note that default values for
attributes only make sense if the attributes themselves are optional, and so
it is an error to specify both a default value and anything other than a
value of optional for use."

Therefore, the "use" attribute takes precedence, hence, your example would
be invalid and would not validate a document instance if the value of "123"
is entered into a prohibited attribute

Ciao!

Andy


-----Original Message-----
From: xmlschema-dev-request@w3.org
[mailto:xmlschema-dev-request@w3.org]On Behalf Of Stanley Guan
Sent: Thursday, March 28, 2002 8:22 PM
To: xmlschema-dev@w3.org
Subject: Re: Attribute Fixed and Prohibited


 Jeni,

Is the following a valid attribute declaration?
  <xs:attribute name="domain" type="xs:positiveInteger" use="prohibited"
   fixed="123"/>
If not, where does it state that in the spec.?

Thx,

-Stanley

> Re: Attribute Fixed and Prohibited
>
> From: Jeni Tennison (jeni@jenitennison.com)
> Date: Wed, Mar 27 2002
>
> *Next message: Andy Del Rio: "RE: ID & IDREF Schema Confusion"
>
>    * Previous message: Jeni Tennison: "Re: Invalid particle derivation by
restriction (XMLSpy vs. MSXML4)"
>    * In reply to: Joey: "Attribute Fixed and Prohibited"
>    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>    * Other mail archives: [this mailing list] [other W3C mailing lists]
>    * Mail actions: [ respond to this message ] [ mail a new topic ]
>
> --------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------
>
> Date: Wed, 27 Mar 2002 13:23:48 +0000
> From: Jeni Tennison <jeni@jenitennison.com>
> Message-ID: <130400635723.20020327132348@jenitennison.com>
> To: Joey <lpjcoyle@ihc.com>
> CC: xmlschema-dev@w3.org
> Subject: Re: Attribute Fixed and Prohibited
>
> 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
> present:
>
>   <sch:report test="@domain">
>     The domain attribute should not be present.
>   </sch:report>
>
> 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:
>
>   <xs:appinfo>
>     <my:domain>123</my:domain>
>   </xs:appinfo>
>
> 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
> document.
>
> Cheers,
>
> Jeni
>
> ---
> Jeni Tennison
> http://www.jenitennison.com/
>
> --------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
------------
>
>    * Next message: Andy Del Rio: "RE: ID & IDREF Schema Confusion"
>    * Previous message: Jeni Tennison: "Re: Invalid particle derivation by
restriction (XMLSpy vs. MSXML4)"
>    * In reply to: Joey: "Attribute Fixed and Prohibited"
>    * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>    * Other mail archives: [this mailing list] [other W3C mailing lists]
>    * Mail actions: [ respond to this message ] [ mail a new topic ]
Received on Friday, 29 March 2002 11:08:38 GMT

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