Skip to content

Commit

Permalink
Add the DOM XPath interfaces from the WHATWG wiki
Browse files Browse the repository at this point in the history
See also https://wiki.whatwg.org/wiki/DOM_XPath. Prose still needs to be added, tracked by #67. This is a one-time exception from the normal WHATWG Working Mode as there's a lot of benefit in hosting these interfaces in a standard as they're implemented in all engines, despite them not being fully defined and tested.

Co-Authored-By: Sam Sneddon <me@gsnedders.com>
  • Loading branch information
2 people authored and annevk committed Aug 30, 2019
1 parent a93f9f8 commit dea5d92
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions dom.bs
Original file line number Diff line number Diff line change
Expand Up @@ -9855,6 +9855,88 @@ the given value.



<h2 id=xpath>XPath</h2>

<p class=XXX><cite>DOM Level 3 XPath</cite> defined an API for evaluating <cite>XPath 1.0</cite>
expressions. These APIs are widely implemented, but have not been maintained. The interface
definitions are maintained here so that they can be updated when <cite>Web IDL</cite> changes.
Complete definitions of these APIs remain necessary and such work is tracked and can be contributed
to in <a href="https://github.com/whatwg/dom/issues/67">whatwg/dom#67</a>. [[DOM-Level-3-XPath]]
[[XPath]] [[WEBIDL]]


<h3 id=interface-xpathresult>Interface {{XPathResult}}</h3>

<pre class=idl>
[Exposed=Window]
interface XPathResult {
const unsigned short ANY_TYPE = 0;
const unsigned short NUMBER_TYPE = 1;
const unsigned short STRING_TYPE = 2;
const unsigned short BOOLEAN_TYPE = 3;
const unsigned short UNORDERED_NODE_ITERATOR_TYPE = 4;
const unsigned short ORDERED_NODE_ITERATOR_TYPE = 5;
const unsigned short UNORDERED_NODE_SNAPSHOT_TYPE = 6;
const unsigned short ORDERED_NODE_SNAPSHOT_TYPE = 7;
const unsigned short ANY_UNORDERED_NODE_TYPE = 8;
const unsigned short FIRST_ORDERED_NODE_TYPE = 9;

readonly attribute unsigned short resultType;
readonly attribute unrestricted double numberValue;
readonly attribute DOMString stringValue;
readonly attribute boolean booleanValue;
readonly attribute Node? singleNodeValue;
readonly attribute boolean invalidIteratorState;
readonly attribute unsigned long snapshotLength;

Node? iterateNext();
Node? snapshotItem(unsigned long index);
};
</pre>


<h3 id=interface-xpathexpression>Interface {{XPathExpression}}</h3>

<pre class=idl>
[Exposed=Window]
interface XPathExpression {
// XPathResult.ANY_TYPE = 0
XPathResult evaluate(Node contextNode, optional unsigned short type = 0, optional XPathResult? result = null);
};
</pre>


<h3 id=mixin-xpathevaluatorbase>Mixin {{XPathEvaluatorBase}}</h3>

<pre class=idl>
callback interface XPathNSResolver {
DOMString? lookupNamespaceURI(DOMString? prefix);
};

interface mixin XPathEvaluatorBase {
[NewObject] XPathExpression createExpression(DOMString expression, optional XPathNSResolver? resolver = null);
XPathNSResolver createNSResolver(Node nodeResolver);
// XPathResult.ANY_TYPE = 0
XPathResult evaluate(DOMString expression, Node contextNode, optional XPathNSResolver? resolver = null, optional unsigned short type = 0, optional XPathResult? result = null);
};
Document includes XPathEvaluatorBase;
</pre>


<h3 id=interface-xpathevaluator>Interface {{XPathEvaluator}}</h3>

<pre class=idl>
[Exposed=Window, Constructor]
interface XPathEvaluator {};

XPathEvaluator includes XPathEvaluatorBase;
</pre>

<p class=note>For historical reasons you can both construct {{XPathEvaluator}} and access the same
methods on {{Document}}.



<h2 id=historical>Historical</h2>

<p>As explained in <a href="#goals">goals</a> this standard is a significant revision of various
Expand Down

0 comments on commit dea5d92

Please sign in to comment.