https://wiki.whatwg.org/api.php?action=feedcontributions&user=Peterv&feedformat=atom
WHATWG Wiki - User contributions [en]
2024-03-29T10:32:25Z
User contributions
MediaWiki 1.39.3
https://wiki.whatwg.org/index.php?title=DOM_XPath&diff=9740
DOM XPath
2014-10-22T18:09:00Z
<p>Peterv: Add some more interfaces and correct existing ones</p>
<hr />
<div>If someone ever decides to write down DOM XPath (i.e. a proper version of the [http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html DOM3XPath note]), take this into account:<br />
<br />
* Integrate the XPath part of the section [http://www.whatwg.org/C#interactions-with-xpath-and-xslt Interactions with XPath and XSLT] from HTML.<br />
* Make it clear that contrary to XPath 1.0 multiple Text nodes can indeed be returned, even if they are siblings. The DOM is not the XML InfoSet. (As is the case in WebKit and Gecko today.)<br />
* Simplifications: http://lists.w3.org/Archives/Public/public-webapps/2011AprJun/0310.html<br />
* Exceptions: https://bugzilla.mozilla.org/show_bug.cgi?id=743888<br />
<br />
== WebIDL interfaces ==<br />
<pre><br />
interface XPathResult {<br />
const unsigned short ANY_TYPE = 0;<br />
const unsigned short NUMBER_TYPE = 1;<br />
const unsigned short STRING_TYPE = 2;<br />
const unsigned short BOOLEAN_TYPE = 3;<br />
const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4;<br />
const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5;<br />
const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6;<br />
const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7;<br />
const unsigned short ANY_UNORDERED_NODE_TYPE = 8;<br />
const unsigned short FIRST_ORDERED_NODE_TYPE = 9;<br />
<br />
readonly attribute unsigned short resultType;<br />
readonly attribute unrestricted double numberValue;<br />
// Maybe "DOMString?".<br />
readonly attribute DOMString stringValue;<br />
readonly attribute boolean booleanValue;<br />
readonly attribute Node singleNodeValue;<br />
readonly attribute boolean invalidIteratorState;<br />
readonly attribute unsigned long snapshotLength;<br />
Node? iterateNext();<br />
Node? snapshotItem(unsigned long index);<br />
};<br />
<br />
interface XPathExpression {<br />
XPathResult evaluate(Node contextNode,<br />
unsigned short type,<br />
object? result);<br />
};<br />
<br />
callback interface XPathNSResolver<br />
{<br />
DOMString? lookupNamespaceURI(DOMString? prefix);<br />
};<br />
<br />
[Constructor]<br />
interface XPathEvaluator {<br />
XPathExpression createExpression(DOMString expression, <br />
XPathNSResolver? resolver);<br />
XPathNSResolver createNSResolver(Node nodeResolver);<br />
XPathResult evaluate(DOMString expression, <br />
Node contextNode, <br />
XPathNSResolver? resolver, <br />
unsigned short type, <br />
object? result);<br />
};<br />
Document implements XPathEvaluator;<br />
</pre><br />
<br />
Indeed, you can both construct this object and access its methods on Document. Isn't the world wonderful?<br />
<br />
[[Category:Spec coordination]]</div>
Peterv