14.3. Foreign AttributesAlthough xs:annotation is certainly the most flexible way to embed any information within a schema, W3C XML Schema defines a second opening in its vocabulary that may be used either as an alternative or in conjunction with annotations. All the W3C XML Schema elements (except xs:documentation and xs:appinfo) accept any attribute that has a namespace other than the W3C XML Schema namespace (unprefixed attributes are forbidden). Such attributes may be used to document a schema: <xs:element name="author" type="author" doc:doc="This element describes the author of a book." xmlns:doc="http://dyomedea.com/ns/doc"/> This approach is also used by SAF adornments, whose simple form can be embedded in attributes: <xs:element name="author" type="author" sql:table="TBL_AUTHOR" xmlns:sql="http://www.extensibility.com/saf/spec/safsample/sql-map.saf" /> The huge opening given to attributes is especially interesting with attribute-only vocabularies such as XLink, and simple XLinks can be directly embedded into W3C XML Schema. The following example links the definition of our author element directly to a XSLT template: <xs:element name="author" type="author" 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"/> Unfortunately, because of the exception for xs:appinfo and xs:documentation, which do not accept foreign attributes, metadata cannot be added through attributes in these elements, so the following example is invalid:
Of course, the usual limitations of attributes apply here: attributes are less extensible than elements and they cannot include structured content.
Copyright © 2002 O'Reilly & Associates. All rights reserved. |
|