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


Help: OASIS Mailing Lists Help | MarkMail Help



   XSchema Spec Section 2.4, Draft 2

[ Lists Home | Date Index | Thread Index ]
  • From: "Simon St.Laurent" <SimonStL@classic.msn.com>
  • To: "Xml-Dev (E-mail)" <xml-dev@ic.ac.uk>
  • Date: Wed, 24 Jun 98 15:19:45 UT

This is a significantly revised version of the original section 2.4, thanks to 
comments from Ron Bourret and John Cowan.  It does not yet include John's 
ATTGroup proposal, which I'd like to see discussed, or the ID suggestion he 

Examples in this version should be clearer. Indentation is coming, as soon as 
I can find the time to insert non-ignorable whitespace.  (The whitespace black 
hole claims another victim...)

A prettier version is available at http://purl.oclc.org/NET/xschema.

Simon St.Laurent
Dynamic HTML: A Primer / XML: A Primer / Cookies

2.4 Attribute Declarations

2.4.1 Overview

Attribute declarations are made with XSC:AttDef elements nested inside of the 
element declaration. The data type of an attribute is defined with a 
sub-element, as is a declaration of whether or not it is required and a 
possible default value.

<!ELEMENT XSC:AttDef (Doc?, (CData | ID | IDRef | IDRefs | Entity | Entities | 
NmToken | NmTokens | NotationType | EnumerationType),(Required | Implied | 
Fixed | AttValue))>
<!-- Name is the name of the attribute -->

<!-- XSC:CData through XSC:EnumerationValue identify attribute types -->
<!ELEMENT XSC:NotationType (NotationValue+)>
<!ELEMENT XSC:NotationValue EMPTY>
<!ATTLIST XSC:NotationValue 
<!ELEMENT XSC:EnumerationType (EnumerationValue+)>
<!ELEMENT XSC:EnumerationValue (Doc?)>
<!ATTLIST XSC:EnumerationValue

<!--XSC:Required through XSC:AttValue identify attribute declarations and 

In XSchema 1.0, an attribute declaration (XSC:AttDef element) must be nested 
within the element declaration (XSC:ElementDecl element) for the element to 
which the attribute belongs. The name attribute of the XSC:AttDef element 
provides the name by which the attribute will be identified. A nested 
declaration is shown below.

<XSC:ElementDecl name="Species">
<XSC:AttDef name="status">

This declares an element with the name Species that has an attribute named 

Merely naming an attribute is inadequate. Attribute declarations must identify 
data types and provide information about whether the attribute is required. 
Both sets of information are declared using subelements. The simplest 
attribute declaration possible identifies an attribute as containing character 
data (CData) and allows the attribute to be optional, as shown below.
<XSC:AttDef name="sampleAttribute">

2.4.2 Attribute Types

XSchema 1.0 provides equivalents for all of the XML 1.0 DTD attribute types. 
Most of them are declared using empty elements, though notations and 
enumerated values are identified with nested sub-elements. All of the examples 
in this section will use the Implied attribute default (and therefore the 
XSC:Implied element.)

The CData attribute type is one of the most common, permitting an attribute to 
contain character data as defined by the XML 1.0 specification. If the Species 
element were to contain an attribute providing the Latin name of the species, 
the declaration would look like the following.

<XSC:ElementDecl name="Species">
<XSC:AttDef name="Latin">

This attribute would then be available for use in instances of the Species 

<Species Latin="Passerina cyanea">...additionalContent...</Species>

The XSC:ID attribute type is used to uniquely identify elements in a document 
for application processing. XSC:IDRef and XSC:IDRefs attribute types are used 
to refer to a single ID value in the same document or multiple ID values in 
the same document, separated by whitespace, respectively. These attribute 
declarations should be use with the same constraints as apply to ID, IDREF, 
and IDREFS attribute types in XML 1.0.

The Entity and Entities attribute types identify the names of unparsed 
entities. The use of these attribute types should be made with the same 
constraints as apply to the ENTITY and ENTITIES attribute types in XML 1.0. If 
a document is checked directly against an XSchema without a conversion to a 
DTD, information regarding unparsed entities must be available from the parser 
for these attribute types to be meaninful.

The Nmtoken and Nmtokens attribute types are used to declare attributes that 
must contain information conforming to the Nmtoken and Nmtokens productions in 
XML 1.0.

The NotationType and EnumeratedType attribute types are more complex, 
requiring nested elements to identify their possible content. These two 
declarations use similar syntax, but the allowed values of NotationType 
declarations must match the Notations declared elsewhere in the XSchema 

If the status attribute of the Species element were to allow the values of 
extinct, endangered, protected, and non-threatened, an appropriate enumerated 
type declaration would look like:

<XSC:ElementDecl name="Species">
<XSC:AttDef name="status">
<XSC:EnumerationValue Value="extinct"/>
<XSC:EnumerationValue Value="endangered"/>
<XSC:EnumerationValue Value="protected"/>
<XSC:EnumerationValue Value="non-threatened"/>

A Species element created conforming to this declaration might look like:
<Species status="extinct">...additionalContentAboutDodos...</Species>

2.4.3 Attribute Defaults

XSchema requires attribute declarations to provide information about the 
default value of a given attribute. XSchema provides for the four cases 
supported by XML 1.0: #REQUIRED, #IMPLIED, #FIXED AttValue, and AttValue. Each 
of these cases is supported by a particular element in the XSchema syntax. 
There may be only one default value declaration per attribute.

Required attributes (identified in XML 1.0 by #REQUIRED) are identified by the 
use of the XSC:Required element. For instance, if the Latin attribute 
described above was required by the Species element, the XSC:AttDef element 
would contain an XSC:Required element:

<XSC:ElementDecl name="Species">
<XSC:AttDef name="Latin">

Optional attributes (identified in XML 1.0 by #IMPLIED) are identified by the 
use of the XSC:Implied element. Implied indicates that there is no default 
value provided, and also that no value is required. If the Latin attribute is 
optional, the XSC:AttDef element would contain an XSC:Implied element:

<XSC:ElementDecl name="Species">
<XSC:AttDef name="Latin">

Fixed attributes (identified in XML 1.0 by #FIXED AttValue) are identified 
through the use of the XSC:Fixed element, which also contains the fixed value 
for the attribute. Attributes declared using fixed value cannot declare a 
different value for that attribute. Fixed effectively hard codes attribute 
values into particular elements. If the Species element had a planet 
attribute, an XSC:Fixed element would identify the fixed nature of the 
attribute and provide the value.

<XSC:ElementDecl name="Species">
<XSC:AttDef name="planet">
<XSC:Fixed Value="Earth"/>

Attributes may also be provided with a default value that may be overridden by 
other declarations. These default values are identified through the use of the 
AttValue element. The status attribute of species elements described above 
would be an appropriate target for such a default value, especially if most 
species being described fell into a particular category:

<XSC:ElementDecl name="Species">
<XSC:AttDef name="status">
<XSC:EnumerationValue Value="extinct"/>
<XSC:EnumerationValue Value="endangered"/>
<XSC:EnumerationValue Value="protected"/>
<XSC:EnumerationValue Value="non-threatened"/>
<XSC:AttValue Value="non-threatened"/>

Any type of default (required, fixed, etc.) may be used with any attribute 
type, though default values should always correspond to acceptable values for 
the attribute type.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)


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

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