[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSchema Spec Section 2.4, Draft 1

  • From: "Simon St.Laurent" <SimonStL@c...>
  • To: "Xml-Dev (E-mail)" <xml-dev@i...>
  • Date: Tue, 23 Jun 98 15:36:12 UT

xschema empty element
The draft for attribute declarations follows.  I really started wishing we'd 
cut it down to CDATA and Enumerated types after a while, but see what you 
think.

It's based on the John Cowan/Ron Bourret DTD, with the following 
modifications:

1) The attribute type declaration is required (the DTD used a ?, but I'd like 
to enforce this for now)

2) I removed a syntax attribute from the XSC:CData element that served some 
metadata purpose but whose contents weren't clearly defined.  We need to 
figure out what to do about this.

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 an empty 
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 -->
<!ATTLIST XSC:AttDef name NMTOKEN #REQUIRED >

<!-- XSC:CData through XSC:EnumerationValue identify attribute types -->
<!ELEMENT XSC:CData EMPTY>
<!ELEMENT XSC:ID EMPTY>
<!ELEMENT XSC:IDRef EMPTY>
<!ELEMENT XSC:IDRefs EMPTY>
<!ELEMENT XSC:Entity EMPTY>
<!ELEMENT XSC:Entities EMPTY>
<!ELEMENT XSC:NmToken EMPTY>
<!ELEMENT XSC:NmTokens EMPTY>
<!ELEMENT XSC:NotationType (NotationValue+)>
<!ELEMENT XSC:NotationValue EMPTY>
<!ATTLIST XSC:NotationValue 
Notation IDREF #REQUIRED>
<!ELEMENT XSC:EnumerationType (EnumerationValue+)>
<!ELEMENT XSC:EnumerationValue (Doc?)>
<!ATTLIST XSC:EnumerationValue
Value NMTOKEN #REQUIRED>

<!--XSC:Required through XSC:AttValue identify attribute declarations and 
defaults-->
<!ELEMENT XSC:Required EMPTY>
<!ELEMENT XSC:Implied EMPTY>
<!ELEMENT XSC:Fixed EMPTY>
<!ATTLIST XSC:Fixed
	Value CDATA #REQUIRED>
<!ELEMENT XSC:AttValue EMPTY>
<!ATTLIST XSC:AttValue
	Value CDATA #REQUIRED>

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">
...additionalElementInformation... 
<XSC:AttDef name="status">
...additionalAttributeInformation... 
</XSC:AttDef>
</XSC:ElementDecl>

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

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">
<XSC:CData/>
<XSC:Implied/>
</XSC:AttDef>

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 identifying the author of the species 
description, the declaration would look like the following.

<XSC:ElementDecl name="Species">
...additionalElementInformation... 
<XSC:AttDef name="author">
<XSC:CData/>
<XSC:Implied/>
</XSC:AttDef>
</XSC:ElementDecl>

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

<Species author="Jim Tiger">...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 
document.

If the extinct 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">
...additionalElementInformation... 
<XSC:AttDef name="status">
<XSC:EnumerationType>
<XSC:EnumerationValue Value="extinct"/>
<XSC:EnumerationValue Value="endangered"/>
<XSC:EnumerationValue Value="protected"/>
<XSC:EnumerationValue Value="non-threatened"/>
</XSC:EnumerationType>
<XSC:Implied/>
</XSC:AttDef>
</XSC:ElementDecl>

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 author attribute 
described above was required by the Species element, the XSC:AttDef element 
would contain an XSC:Required element:

<XSC:ElementDecl name="Species">
...additionalElementInformation... 
<XSC:AttDef name="author">
<XSC:CData/>
<XSC:Required/>
</XSC:AttDef>
</XSC:ElementDecl>

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 author attribute 
is optional, the XSC:AttDef element would contain an XSC:Implied element:

<XSC:ElementDecl name="Species">
...additionalElementInformation... 
<XSC:AttDef name="author">
<XSC:CData/>
<XSC:Implied/>
</XSC:AttDef>
</XSC:ElementDecl>

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 fixed value for 
formatting used by an application, an XSC:Fixed element would identify the 
fixed nature of the attribute and provide the value.

<XSC:ElementDecl name="Species">
...additionalElementInformation... 
<XSC:AttDef name="orgType">
<XSC:CData/>
<XSC:Fixed Value="section"/>
</XSC:AttDef>
</XSC:ElementDecl>

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">
...additionalElementInformation... 
<XSC:AttDef name="status">
<XSC:EnumerationType>
<XSC:EnumerationValue Value="extinct"/>
<XSC:EnumerationValue Value="endangered"/>
<XSC:EnumerationValue Value="protected"/>
<XSC:EnumerationValue Value="non-threatened"/>
</XSC:EnumerationType>
<XSC:AttValue Value="non-threatened"/>
</XSC:AttDef>
</XSC:ElementDecl>

Any type of default value 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@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.