The manakai project

Web::DOM::XPathEvaluator

The DOM XPathEvaluator object

DESCRIPTION

The Web::DOM::XPathEvaluator class implements the DOM XPathEvaluator interface. It is a superinterface of the Document interface, but it can also be used as a standalone object.

METHODS

Following methods are available:

$eval = new Web::DOM::XPathEvaluator

Create a new XPathEvaluator object. [DOMXPATH]

$expr = $eval->create_expression ($string, $resolver)

Parse the specified string as an XPath 1.0 expression and returns it as a new Web::DOM::XPathExpression object. If a code reference or a Web::DOM::XPathNSResolver object is also specified as the optional second argument, it is used as the namespace prefix resolver. [DOMXPATH]

See also "DEPENDENCY" in Web::DOM.

$resolver = $eval->create_ns_resolver ($node)

Create a Web::DOM::XPathNSResolver object with the specified Web::DOM::Node object. [DOMXPATH]

$result = $eval->evaluate ($string, $node, $resolver, $result_type, $result)

Parse and evaluate an XPath 1.0 expression. The first argument is an XPath 1.0 expression to be evaluated. The second argument is the context node (Web::DOM::Node object) used to evaluate the expression. The remainging arguments are optional. The third argument is the namespace prefix resolver, specified as either a code reference or the Web::DOM::XPathResolver object. The fourth argument is the requested result type, specified by one of constants in Web::DOM::XPathResult. The fifth argument is ignored. The method returns the Web::DOM::XPathResult object containing the evaluation result. [DOMXPATH] [DOMPERL]

See also "DEPENDENCY" in Web::DOM.

SPECIFICATIONS

DOMXPATH

Document Object Model XPath <http://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator>.

DOM XPath <http://wiki.whatwg.org/wiki/DOM_XPath>.

Improving DOM Traversal and DOM XPath <http://lists.w3.org/Archives/Public/public-webapps/2011AprJun/0310.html>.

743888 - Replace SVGException and XPathException with DOMException <https://bugzilla.mozilla.org/show_bug.cgi?id=743888#c1>.

The definition for the evaluate method MUST be modified as follows:

  partial interface XPathEvaluator {
    XPathResult evaluate(DOMString expression,
                         (Node or Attr) contextNode,
                         XPathNSResolver? resolver,
                         optional unsigned short type = 0,
                         optional object? result = null);
  };

The set of variable bindings MUST be empty. Additional functions MUST NOT be added to the function library.

The evaluate method MUST accept any type of Node as the contextNode argument, i.e. as the context node of the evaluation.

When an evaluation is failed due to a non-syntax non-namespace error, a SyntaxError DOMException MUST be thrown.

The callback this value used when an XPathNSResolver (specified as a function) is invoked is the callback function itself.

If the XPathNSResolver throws an exception, it MUST be catched and act as if the null value is returned.

When the evaluation is initiated, the context position and context size MUST be set to 1.

The evaluate method MUST return a newly created XPathResult object. It MUST NOT return the WRONG_DOCUMENT_ERR or NOT_SUPPORTED_ERR.

DOMPERL

manakai's DOM Perl Binding <http://suika.suikawiki.org/~wakaba/wiki/sw/n/manakai%27s%20DOM%20Perl%20Binding>.

SEE ALSO

Web::DOM::Document, Web::DOM::XPathResult.

AUTHOR

Wakaba <wakaba@suikawiki.org>.

LICENSE

Copyright 2013 Wakaba <wakaba@suikawiki.org>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.