XML News from Tuesday, October 30, 2007

The W3C Semantic Web Best Practices and Deployment Working Group and HTML Working Groups have published a new working draft of RDFa Primer 1.0.

Current Web pages, written in XHTML, contain inherent structured data: calendar events, contact information, photo captions, song titles, copyright licensing information, etc. When authors and publishers can express this data precisely, and when tools can read it robustly, a new world of user functionality becomes available, letting users transfer structured data between applications and Web sites. An event on a Web page can be directly imported into a desktop calendar. A license on a document can be detected to inform the user of his rights automatically. A photo's creator, camera setting information, resolution, and topic can be published as easily as the original photo itself.

This document is an introduction to RDFa, a method for achieving precisely this kind of structured data embedding in XHTML. The normative specification of RDFa may be found in [RDFa-SYNTAX].

Here's a syntax example from the draft:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns:cal="http://www.w3.org/2002/12/cal/ical#"
      xmlns:contact="http://www.w3.org/2001/vcard-rdf/3.0#">
  <head>
    <title>Jo's Friends and Family Blog</title>
  </head>

  <body>
...
  <p instanceof="cal:Vevent">
    I'm holding
    <span property="cal:summary">
      one last summer Barbecue,
    </span>
    on
    <span property="cal:dtstart" content="20070916T1600-0500">

      September 16th at 4pm.
    </span>
  </p>
...
  <p class="contactinfo" about="http://example.org/staff/jo">
    <span property="contact:fn">Jo Smith</span>.
    <span property="contact:title">Web hacker</span>

    at
    <a rel="contact:org" href="http://example.org">
      Example.org
    </a>.
    You can contact me
    <a rel="contact:email" href="mailto:jo@example.org">
      via email
    </a>.
  </p>
...
    </body>

</html>

The thing that jumps out at me are the use of namespace prefixes in attribute values. Haven't we learned by now that this is a bad idea?


The W3C Web API working group has posted the fourth public working draft of the Selectors API. "It is often desirable to perform script and or DOM operations on a specific set of elements in a document. Selectors [Selectors], mostly used in CSS [CSS21] context, provides a way of matching such a set of elements. This specification introduces two methods which take a group of selectors (often simply referred to as selector) as argument and return the matched elements as result." The spec offers the following JavaScript example:

var i = 0;
function resolver(prefix) {

  var ns = ["http://example.org/foo",
            "http://example.org/bar",
            "http://example.org/baz"];
  return ns[i++];
}

var x = document.querySelectorAll("foo|x, foo|y, bar|z", resolver);

Once again we see how namespaces take a relatively straightforward idea, and turn it into an illegible mess. :-(