|
Level 3 DOM - Be Heard and Help Make Change By Aaron Skinner, additional views by XML developers After looking over the recently released DOM Level 3 requirements document, there has been some discussion on adding an addressing API (similar to the selectNodes function in MSXML). The proposed idea is to introduce a method on the Node interface that takes a scheme specific addressing expression (e.g., XPath 1.0, the product of the XQL WG, etc...) and returns a NodeList:
NodeList getNodes(scheme, expression)
The scheme identifies that language used in the expression. Today, the main standard addressing language in place is XPath 1.0, but this makes the API extensible for future versions of XPath or other languages (similar to the way XPointer works). With something like this in place, DOM developers can harness the power of XPath to simplify typical navigation tasks in a standard way:
NodeList books = doc.getNodes("xpath", "/books//book[@topic='xml']/author");
The default scheme could also be specified for the entire Document so it doesn't have to specified on each method call. Similar functionality could also be added to the Traversal API (as another constructor type to NodeIterator and TreeWalker). In order to help the DOM WG decide on such an issue, the goal of this posting is to gather the general interest level from the xml-dev'ers. Who wants it? Let us know by posting to info@idevresource, cc'ing you mails via [email protected]. We'll post all responses here. You can also make any points about this in the iDevResource forums Views of Richard Anderson - XML author and Developer I've not read the level 3 spec as yet, but here are a few thoughts.. Microsoft, IBM and Vivid Creations support this functionality today, so it is common enough to add I think today. If the W3 do not add it, more incompatibility will grow in the DOM arena. With regard to your proposed syntax, I'd prefer:
NodeList books = doc.getNodes("xpath:/books//book[@topic='xml']/author");
With the default being xpath, overrideable at the document level as you say:
document.setDefaultSearchSchema("xpath");
EVERYbody is already using this, and will continue to us it whatever the W3C do. It is very strange not to add it, and I already feel the W3C just don't keep up with the pace of innovation anyway. Richard Anderson Contribute to IDR: To contribute an article to IDR, a click here.
|
|