XML technologies / XML / XML in a Nutshell / XLinks / DTDs for XLinks

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

For a document containing XLinks to be valid, all XLink attributes used by the document, like all other attributes, must be declared in a DTD. In most cases, some attributes can be declared as #FIXED, so they need not be included explicitly in the document itself. For example, this DTD fragment describes the roman element you already know:

<!ELEMENT roman  (titel, autor, jahr)>
<!ATTLIST roman  xmlns:xlink CDATA   #FIXED 'http://www.w3.org/1999/xlink' xlink:type (simple) #FIXED 'simple' xlink:href  CDATA   #REQUIRED>
<!ELEMENT titel  (#PCDATA)>
<!ELEMENT autor  (#PCDATA)>
<!ELEMENT jahr   (#PCDATA)>

If this DTD specifies the fixed attributes xmlns:xlink and xlink:type, a roman element needs only the attribute xlink:href, to form a complete simple XLink:

<roman xlink:href = "urn:isbn:0688069444">
  <titel>The Wonderful Wizard of Oz</title>
  <autor>L. Frank Baum</author>
  <jahr>1900</jahr>
</roman>

Documents containing many XLink elements often use parameter entity references to define frequently used attributes. For example, suppose that roman, anthologie and sachbuch are simple XLink elements. Their XLink attributes could be declared in a DTD as follows:

<!ENTITY % simplelink
  "xlink:type (simple) #FIXED 'simple'
   xlink:href  CDATA   #REQUIRED
   xmlns:xlink CDATA   #FIXED 'http://www.w3.org/1999/xlink'
   xlink:role  CDATA   #IMPLIED
   xlink:title CDATA   #IMPLIED
   xlink:actuate (onRequest | onLoad | other | none) 'onRequest'
   xlink:show (new | replace | embed | other | none) 'new'">
<!ATTLIST anthologie   %simplelink;>
<!ATTLIST roman        %simplelink;>
<!ATTLIST sachbuch     %simplelink;>

Similar techniques can be used to declare attributes for extended XLinks.

  

 

 

 

back to top