- From: Curt Arnold <carnold@houston.rr.com>
- Date: Fri, 18 Apr 2003 12:24:31 -0500
- To: www-dom@w3.org
Phillipe Le Hegaret commited XPath tests earlier this month that contained the following boilerplate. <!-- The following code is to create the evaluator using either the getFeature method defined in DOM3 or the cast mechanism. Implementation are not required to support both but at least one of them --> <assign var='xpEvaluator' value='null'/> <isSupported obj='doc' feature='"core"' version='"3.0"' var='state'/> <if> <isTrue value='state' /> <getFeature interface='Node' var='xpEvaluator' obj='doc' feature='"XPath"' version='"3.0"'/> </if> <if> <isNull obj='xpEvaluator' /> <assign var='xpEvaluator' value='doc'/> </if> http://www.w3.org/TR/2003/CR-DOM-Level-3-XPath-20030331/xpath.html#XPathEvaluator says: The evaluation of XPath expressions is provided by XPathEvaluator. In a DOM implementation which supports the XPath 3.0 feature, as described above, the XPathEvaluator interface will be implemented on the same object which implements the Document interface permitting it to be obtained by the usual binding-specific method such as casting or by using the DOM Level 3 getInterface method. In this case the implementation obtained from the Document supports the XPath DOM module and is compatible with the XPath 1.0 specification. http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/core.html#Node3-getFeature This method returns a specialized object which implements the specialized APIs of the specified feature and version. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations. This method also allow the implementation to provide specialized objects which do not support the Node interface .... Return Value Node Returns an object which implements the specialized APIs of the specified feature and version, if any, or null if there is no object which implements interfaces associated with that feature. If the DOMObject returned by this method implements the Node interface, it must delegate to the primary core Node and not return results inconsistent with the primary core Node such as attributes, childNodes, etc. ------------------------------ The discussion on obtaining an XPathEvaluator is inconsistent with the DOM 3 Core spec. The getInterface() method does not exist in the current Core draft, it has changed to getFeature(). The XPathEvaluator discussion of binding is stricter than the equivalent discussion in getFeature(). The XPath discussion may be interpreted that casting is always available where the getFeature explicitly disclaims that you cannot depend on casting to obtain a specialized interface. The discussion of Node.getFeature() says: > This method also allow the implementation to provide specialized > objects which do not support the Node interface. If the DOMObject > returned by this method implements the Node interface, it must > delegate to the primary core Node and not return results inconsistent > with the primary core Node such as attributes, childNodes, etc. The method is defined as returning a Node and therefore anything returned from this method must support the Node interface. The text would be appropriate if the return type had been DOMObject. I'd suggest: Change the return type of Node.getFeature() to DOMObject. Add a conformance requirement to DOM XPath that if document.implementation.hasFeature("XPath", version) and document.implementation.hasFeature("Core", "3.0") are true then document.getFeature("XPath", version) must return an instance of XPathEvaluator. Clarify under what conditions being able to cast Document to XPathEvaluator is a conformance requirement. If it always, or is it only required when implementation.hasFeature("Core", "3.0") is false. Rework the description on obtaining an XPathEvaluator. Depending on the resolution of the other issues, there may be no need to XPathEvaluator to be implemented on the same object as Document.
Received on Friday, 18 April 2003 13:24:41 UTC