Chapter 14. Resource Directory Description Language(RDDL)

CONTENTS

Chapter 14. Resource Directory Description Language (RDDL)

  •  14.1 What's at the End of a Namespace URL?
  •  14.2 RDDL Syntax
  •  14.3 Natures
  •  14.4 Purposes

RDDL, the Resource Directory Description Language, is an XML application invented by Jonathan Borden, Tim Bray, and various other members of the xml-dev mailing list to describe XML applications identified by namespace URLs. A RDDL document lives at the namespace URL for the application it describes. RDDL is a hybrid of XHTML Basic and one custom element, rddl:resource. A rddl:resource element is a simple XLink that points to a resource related to the application the RDDL document describes. Humans with browsers can read the XHTML parts to learn about the application. Software can read the rddl:resource elements.

14.1 What's at the End of a Namespace URL?

The people who wrote the namespaces specification couldn't agree on what should be put at the end of a namespace URL. Should it be a DTD, a schema, a specification document, a stylesheet, software for processing the application, or something else? All of these are possible, but none of them are required for any particular XML application. Some applications have DTDs; some don't. Some applications have schemas; some don't. Some applications have stylesheets; some don't. Thus, for the most part, namespaces have been purely formal identifiers. They do not actually locate or identify anything.

Namespaces in XML specifically states that "The namespace name, to serve its intended purpose, should have the characteristics of uniqueness and persistence. It is not a goal that it be directly usable for retrieval of a schema (if any exists)." That is, it is not required that there be anything in particular, such as a DTD or a schema, at the end of the namespace URL. Indeed, it's not even required that the namespace name be potentially resolvable. It might be an irresolvable URN such as urn:isbn:1565922247. On the other hand, this doesn't say that there can't be anything at the end of a namespace URL, just that there doesn't have to be.

Nonetheless, this hasn't stopped numerous developers from typing namespace URLs into their web browser location bars and filling the error logs at the W3C and elsewhere with 404 Not Found errors. It hasn't stopped weekly questions on the xml-dev mailing list about whether it's possible to parse an XML document on a system that's disconnected from the Net. Eventually, the membership of the xml-dev mailing list reached consensus that it was time to put something at the end of namespace URLs, even if they didn't have to.

However, the question still remained, what to put there? All the reasons for not choosing any one thing to put at the end of a namespace URL still applied. Rick Jelliffe suggested fixing the problem by introducing an additional layer of indirection, and Tim Bray proposed doing it with XHTML and XLinks. Instead of putting just one of these at the end of the namespace URL, an XML document containing a list of all the things related to the XML application identified by that particular URL could be put at the end of the namespace URL.

Experience had proven that when presented with a string beginning with http, developers would type it into a browser location bar.[1] Therefore, the basic syntax of RDDL had to be something that looked reasonable when loaded into a browser: preferably, HTML. Furthermore, to make machine processing simple, it also had to be well-formed, perhaps valid, XML. Naturally, XHTML came to mind, and modular XHTML provided just enough extensibility to permit the extra syntax RDDL needed.

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">     <name>       <first_name>Alan</first_name>       <last_name>Turing</last_name>     </name>     <profession>computer scientist</profession>     <profession>mathematician</profession>     <profession>cryptographer</profession>   </person>   <person born="1918" died="1988">     <name>       <first_name>Richard</first_name>       <middle_initial>P</middle_initial>       <last_name>Feynman</last_name>     </name>     <profession>physicist</profession>     <hobby>Playing the bongoes</hobby>   </person> </people>

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
<!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/"> <head>   <title>An XML Application Describing People</title> </head> <body> <h1>An XML Application Describing People</h1> <rddl:resource xlink:type="simple"   xlink:href="urn:isbn:1565922247"   xlink:role="http://dublincore.org/documents/dcmi-type-vocabulary/#text"   xlink:arcrole="http://www.rddl.org/purposes#normative-reference">   <p>     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).   </p> </rddl:resource> <h2>Related Resources</h2> <p>  Several examples in this book address this application in one way or  another. These include: </p> <ul> <li>  <rddl:resource xlink:type="simple"   xlink:href="http://www.cafeconleche.org/books/xian2/examples/03/3-5.dtd"   xlink:role="http://www.isi.edu/in-notes/iana/assignments/media-types/application/xml-dtd"   xlink:arcrole="http://www.rddl.org/purposes#validation">     <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> </li> <li> <rddl:resource xlink:type="simple"  xlink:href="http://www.cafeconleche.org/books/xian2/examples/08/8-15.xsl"  xlink:role="http://www.w3.org/1999/XSL/Transform"  xlink:arcrole="http://www.isi.edu/in-notes/iana/assignments/media-types/text/html">   <a href="http://www.cafeconleche.org/books/xian2/examples/08/8-15.xsl">     Example 8-15</a>: An XSLT stylesheet for people documents  </rddl:resource> </li> </ul> <p>   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. </p> </body> </html>
Figure 14-1. To a web browser, a RDDL document is just another HTML document

figs/xian2_1401.gif

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.

14.3 Natures

The nature of a related resource says what the resource is. For example, the nature of a web page might be HTML, and the nature of an image might be JPEG. The nature is indicated by a URL. Normally this nature URL is a namespace URL for XML applications and a MIME media type URL for everything else. For instance, the XSLT nature is written as http://www.w3.org/1999/XSL/Transform. The JPEG nature is written as http://www.isi.edu/in-notes/iana/assignments/media-types/image/jpeg.

The RDDL specification specifies two dozen natures that can be used in xlink:role attributes. In addition, you are welcome to define your own, but when possible, you should use the standard natures so that automated software can understand your documents and locate the related resources it needs to locate. These are the standard natures and their URLs:

CSS stylesheet

http://www.isi.edu/in-notes/iana/assignments/media-types/text/css

DTD

http://www.isi.edu/in-notes/iana/assignments/media-types/application/xml-dtd

A mailbox

http://www.rddl.org/natures#mailbox

Generic HTML

http://www.isi.edu/in-notes/iana/assignments/media-types/text/html

HTML 4.0

http://www.w3.org/TR/html4/

HTML 4 Strict

http://www.w3.org/TR/html4/strict

HTML 4 Transitional

http://www.w3.org/TR/html4/transitional

HTML 4 Frameset

http://www.w3.org/TR/html4/frameset

XHTML

http://www.w3.org/1999/xhtml

XHTML 1.0 Strict

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict

XHTML 1.0 Transitional

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional

RDF schema

http://www.w3.org/2000/01/rdf-schema#

RELAX core grammar

http://www.xml.gr.jp/xmlns/relaxCore

RELAX namespace grammar

http://www.xml.gr.jp/xmlns/relaxNamespace

Schematron schema

http://www.ascc.net/xml/schematron

OASIS Open Catalog

http://www.rddl.org/natures#SOCAT

W3C XML Schema Language schema

http://www.w3.org/2000/10/XMLSchema

XML character data

http://www.w3.org/TR/REC-xml.html#dt-chardata

XML escaped text

http://www.w3.org/TR/REC-xml.html#dt-escape

XML unparsed entity

http://www.w3.org/TR/REC-xml.html#dt-unparsed

IETF RFC

http://www.ietf.org/rfc/rfc2026.txt

ISO standard

http://www.iso.ch/

Python software

http://www.rddl.org/natures/software#python

Java software

http://www.rddl.org/natures/software#java

Many other natures can be reasonably derived by following these examples. For instance, a PNG image could be given the nature because http://www.isi.edu/in-notes/iana/assignments/media-types/image/png because PNG documents have the MIME media type image/png. Software written in Ruby could be given the nature http://www.rddl.org/natures/software#ruby. An RDF document can have the nature http://www.w3.org/1999/02/22-rdf-syntax-ns# taken from its namespace, and so forth.

14.4 Purposes

The purpose of a related resource indicates what the resource will be used for. Purposes distinguish between resources with the same natures used for different things. For example, DocBook has multiple XSLT stylesheets for transforming DocBook documents into HTML, XHTML, chunked HTML, and XSL-FO. These are all related resources with the same nature but different purposes. Unlike natures, purposes are optional. You don't have to use them if you don't need to distinguish between resources with the same natures, but you can if you'd like.

Purpose names are URLs. These URLs are placed in xlink:arcrole attributes of a rddl:resource element. The RDDL specification defines almost 20 different well-known purpose URLs, mostly in the form http://www.rddl.org/purposes#purpose. In addition, you are welcome to define your own; but you should use the standard URLs for the standard purposes so that automated software can understand your documents and locate the related resources it needs to locate. These are the well-known purposes:

Validation

http://www.rddl.org/purposes#validation

Schema-validation

http://www.rddl.org/purposes#schema-validation

DTD module

http://www.rddl.org/purposes#module

Schema module

http://www.rddl.org/purposes#schema-module

DTD notations module

http://www.rddl.org/purposes#notations

Software module

http://www.rddl.org/purposes#software-module

Software package

http://www.rddl.org/purposes#software-package

Software project

http://www.rddl.org/purposes#software-project

JAR

http://www.rddl.org/purposes#JAR

XSLT extension

http://www.rddl.org/purposes/software#xslt-extension

Reference

http://www.rddl.org/purposes#reference

Normative reference

http://www.rddl.org/purposes#normative-reference

Non-normative reference

http://www.rddl.org/purposes#non-normative-reference

Prior-version

http://www.rddl.org/purposes#prior-version

Definition

http://www.rddl.org/purposes#definition

Icon

http://www.rddl.org/purposes#icon

Alternate

http://www.rddl.org/purposes#alternate

RDDL Directory

http://www.rddl.org/purposes#directory

Furthermore, the purpose of an XSLT transform is often the URI for the nature of the resource that is produced by the transform. For instance, the purpose of a stylesheet that converted documents into strict XHTML would probably be http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.

[1]  In the immortal words of Claude L. Bullard, "All the handwaving about URN/URI/URL doesn't avoid the simple fact that if one puts http:// anywhere in browser display space, the system colors it blue and puts up a finger. The monkey expects a resource and when it doesn't get one, it shocks the monkey. Monkeys don't read specs to find out why they should be shocked. They turn red and put up a finger."

CONTENTS


XML in a Nutshell
XML in a Nutshell, 2nd Edition
ISBN: 0596002920
EAN: 2147483647
Year: 2001
Pages: 28

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net