OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Please clarify meaning of use="..." for attributes

[ Lists Home | Date Index | Thread Index ]
  • From: "Tolkin, Steve" <Steve.Tolkin@FMR.COM>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 02 Nov 2000 14:26:54 -0500

Below is an an excerpt from the latest XMLScheme.xsd, available from
www.w3c.org/2000/10/XMLSchema.xsd showing the "use" attribute that applies
to attributes.
It can take on 5 possible values: prohibited, optional, required, default,
and fixed.
When is it useful to say "prohibited"?  What exactly does fixed mean?  
I think I understand the other three values.

# answer attribute must be provided
<attribute name="answer" use="required"/> 

# answer attribute can be provided, but if not infoset will have answer="42"
<attribute name="answer" use="default" value="42"/> 

# answer attribute can be provided
<attribute name="answer" use="optional"/> 

Which of the next two comments is correct?
# answer attribute cannot be provided, and infoset has answer="42"
# answer attribute can be omitted, producing 42; or if provided must have
value 42.
<attribute name="answer" use="fixed" value="42"/>

And when would I ever want to say prohibited? Why would't I just omit the
# answser attribute cannot be provided
<attribute name="answer" use="prohibited"/>

 <complexType name="attribute">
   <extension base="annotated">
     <element name="simpleType" minOccurs="0" type="localSimpleType"/>
    <attributeGroup ref="defRef"/>
    <attribute name="type" type="QName"/>
    <attribute name="use" use="default" value="optional">
      <restriction base="NMTOKEN">
       <enumeration value="prohibited"/>
       <enumeration value="optional"/>
       <enumeration value="required"/>
       <enumeration value="default"/>
       <enumeration value="fixed"/>
    <attribute name="value" use="optional" type="string"/>
    <attribute name="form" type="formChoice"/>

Steven Tolkin          steve.tolkin@fmr.com      617-563-0516 
Fidelity Investments   82 Devonshire St. V10D    Boston MA 02109
There is nothing so practical as a good theory.  Comments are by me, 
not Fidelity Investments, its subsidiaries or affiliates.


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS