XML News from Thursday, September 28, 2006

The W3C Web API working group has posted the second 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:

function resolver(str) {
  var prefixes = {
    h:  "http://www.w3.org/1999/xhtml",
    g: "http://www.w3.org/2000/svg"}
  return prefixes[str];
var a = document.matchAll("h|div > g|svg", resolver);
var b = document.matchSingle("div.foo.bar");