2 * Copyright (c) 2004 World Wide Web Consortium,
4 * (Massachusetts Institute of Technology, European Research Consortium for
5 * Informatics and Mathematics, Keio University). All Rights Reserved. This
6 * work is distributed under the W3C(r) Software License [1] in the hope that
7 * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
8 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
13 package org.w3c.dom.xpath;
15 import org.w3c.dom.Node;
16 import org.w3c.dom.DOMException;
19 * The <code>XPathExpression</code> interface represents a parsed and resolved
21 * <p>See also the <a href='http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226'>Document Object Model (DOM) Level 3 XPath Specification</a>.
23 public interface XPathExpression {
25 * Evaluates this XPath expression and returns a result.
26 * @param contextNode The <code>context</code> is context node for the
27 * evaluation of this XPath expression.If the XPathEvaluator was
28 * obtained by casting the <code>Document</code> then this must be
29 * owned by the same document and must be a <code>Document</code>,
30 * <code>Element</code>, <code>Attribute</code>, <code>Text</code>,
31 * <code>CDATASection</code>, <code>Comment</code>,
32 * <code>ProcessingInstruction</code>, or <code>XPathNamespace</code>
33 * node.If the context node is a <code>Text</code> or a
34 * <code>CDATASection</code>, then the context is interpreted as the
35 * whole logical text node as seen by XPath, unless the node is empty
36 * in which case it may not serve as the XPath context.
37 * @param type If a specific <code>type</code> is specified, then the
38 * result will be coerced to return the specified type relying on
39 * XPath conversions and fail if the desired coercion is not possible.
40 * This must be one of the type codes of <code>XPathResult</code>.
41 * @param result The <code>result</code> specifies a specific result
42 * object which may be reused and returned by this method. If this is
43 * specified as <code>null</code>or the implementation does not reuse
44 * the specified result, a new result object will be constructed and
45 * returned.For XPath 1.0 results, this object will be of type
46 * <code>XPathResult</code>.
47 * @return The result of the evaluation of the XPath expression.For XPath
48 * 1.0 results, this object will be of type <code>XPathResult</code>.
49 * @exception XPathException
50 * TYPE_ERR: Raised if the result cannot be converted to return the
52 * @exception DOMException
53 * WRONG_DOCUMENT_ERR: The Node is from a document that is not supported
54 * by the XPathEvaluator that created this <code>XPathExpression</code>
56 * <br>NOT_SUPPORTED_ERR: The Node is not a type permitted as an XPath
57 * context node or the request type is not permitted by this
58 * <code>XPathExpression</code>.
60 public Object evaluate(Node contextNode,
63 throws XPathException, DOMException;