XML technologies / XML Schema / Documenting schemas / Foreign attributes

(Excerpt from “XML Schema” by Eric van der Vlist)

Although xs:annotation is certainly the most flexible way to put arbitrary information in a schema, W3C XML Schema defines another opening in its vocabulary, usable instead of or alongside annotations. Every element of W3C XML Schema, except xs:documentation and xs:appinfo, accepts any attribute with a namespace different from that of W3C XML Schema; unprefixed attributes are forbidden! These attributes can document a schema:

<xs:element name="author" type="authorType" doc:doc="Dieses Element beschreibt den Autor eines Buches." xmlns:doc="http://dyomedea.com/ns/doc"/>

SAF (Schema Adjunct Framework) embellishments also use this approach; their simple form can be embedded in attributes:

<xs:element name="author" type="authorType" sql:table="TBL_AUTHOR" xmlns:sql="http://www.extensibility.com/saf/spec/safsample/sql-map.saf"/>

This broad opening for attributes is especially useful for attribute-only vocabularies such as XLink. Simple XLinks can be embedded directly in W3C XML Schema. The following example links the definition of our author element directly to an XSLT-template:

<xs:element name="author" type="authorType" xlink:arcrole="http://www.w3.org/1999/xhtml" xlink:role="http://www.w3.org/1999/XSL/Transform" xlink:title="Author template" xlink:href="library.xslt#author" xmlns:xlink="http://www.w3.org/1999/xlink"/>

Because of the exceptions for xs:appinfo and xs:documentation, which accept no foreign attributes, metadata unfortunately cannot be added to these elements through attributes; the following example is therefore invalid:

<xs:element name="author" type="authorType">
   <xs:annotation>
      <xs:appinfo xlink:arcrole="http://www.w3.org/1999/XSL/Transform" xlink:role="http://www.w3.org/1999/XSL/Transform" xlink:title="Author template" xlink:href="library.xslt#author" xmlns:xlink="http://www.w3.org/1999/xlink">
         <div class="resource">
            <h4>XSLT-Transformation</h4>
            <p>Dieses <a href="library.xslt#author">Template</a> zeigt die Beschreibung eines Autors an.</p>
         </div>
      </xs:appinfo>
      <xs:appinfo title="CSS Stylesheet" role="http://www.isi.edu/in-notes/iana/assignments/media-types/text/css" href="author.css">
         <div class="resource">
            <h4>CSS-Stylesheet</h4>
            <p>Ein <a href="author.css">CSS-Stylesheet</a>, das die Stile definiert, die zur Anzeige eines Autors verwendet werden können.</p>
         </div>
      </xs:appinfo>
   </xs:annotation>
</xs:element>

The usual attribute restrictions apply: attributes are less extensible than elements and cannot hold structured content.

   

 

 

 

back to top