The w3c only define specifications (XML, XSLT, DOM, etc...) and are not trying to align the API to any specific language or platform.
Its intended for developer of parsers as a guideline to produce a product compliant with existing code that uses these parsers.
When you build your application framework, it's best to wrap all API calls so you can control how the API is accessed in different language or on different platforms.
In Java, JavaScript, C# or whatever your using, create a class\object that wraps accessing the API calls. In JavaScript it will help when making code cross-browser compliant, if your publishing your solution for multiple platforms, you will only have to update your wrapper class.
Here is an example below, however, you can get as fancy as you want, define your own wrapper interface and base class with descendent classes overriding to provide specific implementations.
function XMLNode(xnode) {
this.xnode = xnode;
}
function getNodes(path, xnode) {
if (browseTYPE != IE) {
//Ordered SnapShot
if (xnode.evaluate)
fld = xnode.evaluate(path, xnode, null, 7, null);
else
fld = xnode.ownerDocument.evaluate(path, xnode, null, 7, null);
//We need a result wrapper here
if (fld != null) return new XMLSnapShotList(fld);
} else {
fld = xnode.selectSingleNode(path).childNodes;
//We need a result wrapper here
if (fld != null) return new XMLList(fld);
}
return null;
}
XMLNode.prototype.getNodes = getNodes;
Iterable
by a lot, and my guess is it's just a completely straightforward "port" of the W3C specification with no regard to "Java-likeness", and nobody really cared about going back to figure out how to make the API nicer and not break compatibility. (See also:Calendar
.) – Assign