XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.

advertisement

Answering the Namespace Riddle

February 28, 2001

An Introduction to the Resource Directory Description Language

This tutorial introduces the Resource Directory Description Language (RDDL), which is the result of a recent project conducted by the XML-DEV community. It provides an overview of RDDL's very simple vocabulary and the benefits it can bring to XML applications.

Background

Namespaces are now a common feature of any new XML vocabulary. While their use is spreading, there is still a great deal of controversy associated with them. The controversy has generally focused on the choice and use of URIs, or more commonly URLs, as Namespace identifiers. While the XML Namespaces specification notes that URIs were selected merely as a unique identification system, it is silent on the issue of what, if anything, those URIs should point to.

The received wisdom, as documented in the Namespace FAQ, is that these URIs are not meant to point to anything. Paste one into your web browser, and you'll likely get "404 Not Found" error. URLs have become synonymous with web resources -- developers and Internet users alike expect to be able to point their browsers at these URLs and obtain something intelligible.

In response to this expectation, many developers have begun placing useful resources at a namespace URL. For example, the RSS 1.0 specification is found at the RSS namespace URI. Other XML applications place XML schemas, of different varieties, at these URLs, giving a handy place for applications to retrieve schemas during processing.

Table of Contents

An Introduction to the Resource Directory Description Language

Background

Introducing RDDL

Creating a RDDL Document

Natures and Purposes

Developing with RDDL

Conclusion

This unregulated practice, and more importantly the mixture of resources that might appear at these URLs, has lead to controversy in XML circles. Some believe that the practice should be deprecated, others that it must be regulated in some way. Following a recent resurgence of this debate on XML-DEV a consensus was finally reached. A namespace URL should point to a directory of resources rather than a single web page or schema. Thus RDDL was born. Additional background of the debate can be found in a recent XML-Deviant column, "Old Ghosts: XML Namespaces"

Introducing RDDL

RDDL (pronounced "riddle") was designed by Jonathan Borden and Tim Bray in collaboration with members of the XML-DEV mailing list. A number of requirements contributed to the design of the language:

  • Recognize that a plurality of different resources could be associated with a Namespace, no single resource type should be favored
  • Provide machine-readable access to the resource directory
  • Provide human-readable (i.e. browsing) access to the resource directory
  • Use a simple well-defined syntax
  • Recognize that a directory might contain multiple instances of a particular resource type; for example, multiple CSS or XSLT stylesheets

RDDL meets these requirements in the following ways:

Read what Elliotte Rusty Harold, co-author of O'Reilly's XML in a Nutshell, has to say on RDDL in RDDL Me This: What Does a Namespace URL Locate?, on xml.oreilly.com.

  • RDDL documents describe a directory of resources

  • RDDL is derived from the XHTML standard and is therefore accessible using existing browsers

  • The RDDL vocabulary contains only a single element

  • RDDL adds an additional level of indirection to its resource directory, allowing a resource to have both a nature and a purpose

The details of these features are covered in the next section. It is worth noting that RDDL takes advantage of the modularization features of XHTML to build its vocabulary upon XHTML Basic. As it adds but a single new element that borrows features from XLink, it's very accessible to programmers and web developers alike.

Creating a RDDL Document

The XHTML framework

RDDL is layered on XHTML Basic; thus RDDL documents can contain any element from the XHTML Basic module. With this in mind, what follows is a simple template for an RDDL document.

<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
     "http://www.rddl.org/rddl-xhtml.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xlink="http://www.w3.org/1999/xlink"
      xmlns:rddl="http://www.rddl.org/"
      xml:lang="en">
<head>
      <title>My First RDDL Document</title>
      <link href="http://www.rddl.org/xrd.css" type="text/css"
           rel="stylesheet" />
</head>
<body>
<h1>My First RDDL Document</h1>

<-- Body of RDDL document to appear here -->

</body>
</html>

There are several things worth noting about this first example:

  1. The DOCTYPE declaration refers to the RDDL DTD, which has been defined as an XHTML module (see "XHTML Modularization" for more information)
  2. Since the majority of the elements in RDDL are from the XHTML namespace, it's been declared as the default namespace in the document.
  3. The explicit declarations of the RDDL and XLink namespaces
  4. Reference to a CSS stylesheet provided by the RDDL authors for styling RDDL documents; Jonathan Borden has also produced an IE5 behavior.

In all other regards the document is practically identical to any other simple XHTML document; save it to a file and fire up your browser: you'll see the expected result.

Given this initial template we can now begin adding elements from the XHTML and RDDL namespaces.

The resource element

RDDL includes only a single new element, called resource. In fact the element is only required as a placeholder for a number of XLink attributes. RDDL is very simple. If you can understand XHTML and basic XLink, then RDDL is a breeze.

The simplest version of the resource element is as follows:

<rddl:resource
     xlink:href="http://www.bath.ac.uk/~ccslrd/examples/pizzaml/schema.xsd"
     xlink:title="The PizzaML Schema">

<!-- Description of the resource goes here -->

</rddl:resource>

This adds a single resource to the RDDL document. Its location is defined using a simple XLink reference. A title is added for completeness. Additional descriptive text can be associated with a resource using elements from the XHTML namespace. An RDDL element is roughly equivalent to the xhtml:div element and may contain, therefore, the usual mixture of paragraph and textual markup elements.

The following is a more complete example using the XHTML template. In this case we're producing an RDDL document that describes the resources associated with the namespace of a fictitious XML vocabulary for describing pizzas).

<!DOCTYPE html PUBLIC "-//XML-DEV//DTD XHTML RDDL 1.0//EN"
  "http://www.rddl.org/rddl-xhtml.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:rddl="http://www.rddl.org/"
   xml:lang="en"
   xml:base="http://www.bath.ac.uk/~ccslrd/examples/pizzaml/ns/">
<head>
   <title>RDDL Document for the Pizza Description Language</title>
   <link href="http://www.rddl.org/xrd.css" type="text/css" 
     rel="stylesheet"/>
</head>
<body>
   <h1>RDDL Document for the Pizza Description Language</h1>

   <p>
   This document provides a list of resources associated with the Pizza
   description language, PizzaML.
   </p>

   <rddl:resource
     xlink:href="http://www.bath.ac.uk/~ccslrd/examples/pizzaml/schema.xsd"
     xlink:title="The PizzaML XML Schema">

      <p>
      The XML Schema for PizzaML documents is
      <a href="http://www.bath.ac.uk/~ccslrd/examples/pizzaml/schema.xsd">
     available from here</a>.
      </p>

   </rddl:resource>

</body>
</html>

We now have a complete RDDL document containing only a single resource, an XML Schema for PizzaML. Obviously this example is very trivial. In reality a directory is likely to contain all sorts of additional resources. Thus, we need to introduce two additional XLink attributes of the resource element to declare the nature and purpose of a resource in our RDDL directory.

Pages: 1, 2

Next Pagearrow