home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeXML in a NutshellSearch this book

14.2. RDDL Syntax

A RDDL document is an XHTML Basic document, plus one new element, rddl:resource. XHTML Basic is a subset of XHTML that includes the Structure, Text, Hypertext, List, Basic Forms, Basic Tables, Image, Object, Metainformation, Link, and Base modules. There are no frames or deprecated presentational elements like font and bold. However, this is enough to write pretty much anything you'd reasonably want to write about an XML application.

In addition, a RDDL document contains one new element, resource, which is placed in the http://www.rddl.org/ namespace. This URL is normally mapped to the rddl prefix. The prefix can change as long as the URL remains the same. However, the RDDL DTD declares the resource element with the name rddl:resource, so a RDDL document will only be valid if it uses the prefix rddl.

A rddl:resource element is a simple XLink whose xlink:href attribute points to the related resource and whose xlink:role and xlink:arcrole attributes identify the nature and purpose of that related resource. The rddl:resource element can appear anywhere a p element can appear and contain anything a div element can contain. Web browsers generally ignore the rddl:resource start- and end-tags, but will display their content. Automated software searching for related resources only pays attention to the rddl:resource elements and their attributes, while ignoring all the XHTML.

Recall the person vocabulary used several times in this book. When last seen in Chapter 8, it looked as shown in Example 14-1. All elements in this document are in the default namespace http://www.cafeconleche.org/namespaces/people.

Example 14-1. An XML document describing two people that uses a default namespace

<?xml version="1.0"?>
<people xmlns="http://www.cafeconleche.org/namespaces/people">

  <person born="1912" died="1954">
    <profession>computer scientist</profession>

  <person born="1918" died="1988">
    <hobby>Playing the bongoes</hobby>


Various chapters have developed stylesheets, DTDs, and (still-to-come) schemas for this application. Example 14-2 is a very simple RDDL document that brings these all together. This document should be placed at the namespace for that application, http://www.cafeconleche.org/namespaces/people. The DOCTYPE declaration loads the RDDL DTD rather than the XHTML Basic DTD, but the difference is only in the addition of the single rddl:resource element. This document is both valid and well-formed. Figure 14-1 shows this document in Mozilla, where it looks like any other HTML document.

Example 14-2. A RDDL document

<html xmlns="http://www.w3.org/1999/xhtml"
  <title>An XML Application Describing People</title>

<h1>An XML Application Describing People</h1>
<rddl:resource xlink:type="simple"
    http://www.cafeconleche.org/namespaces/people is the namespace URL
    for an XML application describing people in a data-oriented
    fashion used as an example in <cite>XML in a Nutshell</cite>, second
    edition by Elliotte Rusty Harold and W. Scott Means (O'Reilly &amp;
    Associates, 2002).

<h2>Related Resources</h2>
 Several examples in this book address this application in one way or
 another. These include:

 <rddl:resource xlink:type="simple"
    <a href="http://www.cafeconleche.org/books/xian2/examples/03/3-5.dtd">
      Example 3-5</a>: A data oriented DTD describing people
<rddl:resource xlink:type="simple"
  <a href="http://www.cafeconleche.org/books/xian2/examples/08/8-15.xsl">
    Example 8-15</a>: An XSLT stylesheet for people documents

  This document itself is
  <a href="http://www.cafeconleche.org/books/xian/examples/14/14-2.html">
   Example 14-2</a> from the RDDL chapter.

Figure 14-1

Figure 14-1. To a web browser, a RDDL document is just another HTML document

This document contains three rddl:resource elements indicating related resources. Two of them are inside list items, and one of them contains a paragraph at the top of the page. The first one links to the unofficial specification for the people application, this book itself. The xlink:href attribute uses an isbn URI to identify the book. The xlink:role contains a URL from the Dublin Core that indicates that the nature of this resource is text. The xlink:arcrole attribute contains a well-known URL defined in the RDDL specification to indicate that the purpose of this resource is normative reference.

The second rddl:resource element points to the DTD first defined in Chapter 3. Its nature is indicated by a MIME media type URL, and its purpose is validation. The xlink:href attribute links to the actual location of the DTD. However, a typical browser won't recognize this, so the rddl:resource element contains an ordinary HTML a link that the browser will color blue and the user can click on. It's not uncommon to duplicate markup in a RDDL document--one set of tags for the machines and another set of tags for the humans--each of which say pretty much the same thing.

The final rddl:resource element points to the XSLT stylesheet defined in Chapter 8. Here the xlink:role attribute contains the namespace URI for XSLT, indicating that this resource is an XSLT stylesheet. The xlink:arcrole attribute contains the MIME media type URL for HTML, indicating that this stylesheet will transform documents into HTML.

This is a very simple example. A real-world RDDL document would contain a lot more HTML to tell people reading it in a browser just what the application was about. Machines will ignore the HTML and look at the xlink:role and xlink:arcrole attributes to figure out exactly what they can do with each related resource.

Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.