286N/A/*
286N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
286N/A *
286N/A * This code is free software; you can redistribute it and/or modify it
286N/A * under the terms of the GNU General Public License version 2 only, as
286N/A * published by the Free Software Foundation. Oracle designates this
286N/A * particular file as subject to the "Classpath" exception as provided
286N/A * by Oracle in the LICENSE file that accompanied this code.
286N/A *
286N/A * This code is distributed in the hope that it will be useful, but WITHOUT
286N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
286N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
286N/A * version 2 for more details (a copy is included in the LICENSE file that
286N/A * accompanied this code).
286N/A *
286N/A * You should have received a copy of the GNU General Public License version
286N/A * 2 along with this work; if not, write to the Free Software Foundation,
286N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
286N/A *
286N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
286N/A * or visit www.oracle.com if you need additional information or have any
286N/A * questions.
286N/A */
286N/A
286N/A/*
286N/A * This file is available under and governed by the GNU General Public
286N/A * License version 2 only, as published by the Free Software Foundation.
286N/A * However, the following notice accompanied the original version of this
286N/A * file and, per its terms, should not be removed:
286N/A *
286N/A * Copyright (c) 2002 World Wide Web Consortium,
286N/A * (Massachusetts Institute of Technology, Institut National de
286N/A * Recherche en Informatique et en Automatique, Keio University). All
286N/A * Rights Reserved. This program is distributed under the W3C's Software
286N/A * Intellectual Property License. This program is distributed in the
286N/A * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
286N/A * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
286N/A * PURPOSE.
286N/A * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
286N/A */
286N/A
286N/Apackage org.w3c.dom.xpath;
286N/A
286N/A
286N/Aimport org.w3c.dom.Node;
286N/Aimport org.w3c.dom.DOMException;
286N/A
286N/A/**
286N/A * The evaluation of XPath expressions is provided by
286N/A * <code>XPathEvaluator</code>. In a DOM implementation which supports the
286N/A * XPath 3.0 feature, as described above, the <code>XPathEvaluator</code>
286N/A * interface will be implemented on the same object which implements the
286N/A * <code>Document</code> interface permitting it to be obtained by the usual
286N/A * binding-specific method such as casting or by using the DOM Level 3
286N/A * getInterface method. In this case the implementation obtained from the
286N/A * Document supports the XPath DOM module and is compatible with the XPath
286N/A * 1.0 specification.
286N/A * <p>Evaluation of expressions with specialized extension functions or
286N/A * variables may not work in all implementations and is, therefore, not
286N/A * portable. <code>XPathEvaluator</code> implementations may be available
286N/A * from other sources that could provide specific support for specialized
286N/A * extension functions or variables as would be defined by other
286N/A * specifications.
286N/A * <p>See also the <a href='http://www.w3.org/2002/08/WD-DOM-Level-3-XPath-20020820'>Document Object Model (DOM) Level 3 XPath Specification</a>.
286N/A */
286N/Apublic interface XPathEvaluator {
286N/A /**
286N/A * Creates a parsed XPath expression with resolved namespaces. This is
286N/A * useful when an expression will be reused in an application since it
286N/A * makes it possible to compile the expression string into a more
286N/A * efficient internal form and preresolve all namespace prefixes which
286N/A * occur within the expression.
286N/A * @param expression The XPath expression string to be parsed.
286N/A * @param resolver The <code>resolver</code> permits translation of
286N/A * prefixes within the XPath expression into appropriate namespace URIs
286N/A * . If this is specified as <code>null</code>, any namespace prefix
286N/A * within the expression will result in <code>DOMException</code>
286N/A * being thrown with the code <code>NAMESPACE_ERR</code>.
286N/A * @return The compiled form of the XPath expression.
286N/A * @exception XPathException
286N/A * INVALID_EXPRESSION_ERR: Raised if the expression is not legal
286N/A * according to the rules of the <code>XPathEvaluator</code>i
286N/A * @exception DOMException
286N/A * NAMESPACE_ERR: Raised if the expression contains namespace prefixes
286N/A * which cannot be resolved by the specified
286N/A * <code>XPathNSResolver</code>.
286N/A */
286N/A public XPathExpression createExpression(String expression,
286N/A XPathNSResolver resolver)
286N/A throws XPathException, DOMException;
286N/A
286N/A /**
286N/A * Adapts any DOM node to resolve namespaces so that an XPath expression
286N/A * can be easily evaluated relative to the context of the node where it
286N/A * appeared within the document. This adapter works like the DOM Level 3
286N/A * method <code>lookupNamespaceURI</code> on nodes in resolving the
286N/A * namespaceURI from a given prefix using the current information
286N/A * available in the node's hierarchy at the time lookupNamespaceURI is
286N/A * called. also correctly resolving the implicit xml prefix.
286N/A * @param nodeResolver The node to be used as a context for namespace
286N/A * resolution.
286N/A * @return <code>XPathNSResolver</code> which resolves namespaces with
286N/A * respect to the definitions in scope for a specified node.
286N/A */
286N/A public XPathNSResolver createNSResolver(Node nodeResolver);
286N/A
286N/A /**
286N/A * Evaluates an XPath expression string and returns a result of the
286N/A * specified type if possible.
286N/A * @param expression The XPath expression string to be parsed and
286N/A * evaluated.
286N/A * @param contextNode The <code>context</code> is context node for the
286N/A * evaluation of this XPath expression. If the XPathEvaluator was
286N/A * obtained by casting the <code>Document</code> then this must be
286N/A * owned by the same document and must be a <code>Document</code>,
286N/A * <code>Element</code>, <code>Attribute</code>, <code>Text</code>,
286N/A * <code>CDATASection</code>, <code>Comment</code>,
286N/A * <code>ProcessingInstruction</code>, or <code>XPathNamespace</code>
286N/A * node. If the context node is a <code>Text</code> or a
286N/A * <code>CDATASection</code>, then the context is interpreted as the
286N/A * whole logical text node as seen by XPath, unless the node is empty
286N/A * in which case it may not serve as the XPath context.
286N/A * @param resolver The <code>resolver</code> permits translation of
286N/A * prefixes within the XPath expression into appropriate namespace URIs
286N/A * . If this is specified as <code>null</code>, any namespace prefix
286N/A * within the expression will result in <code>DOMException</code>
286N/A * being thrown with the code <code>NAMESPACE_ERR</code>.
286N/A * @param type If a specific <code>type</code> is specified, then the
286N/A * result will be returned as the corresponding type.For XPath 1.0
286N/A * results, this must be one of the codes of the
286N/A * <code>XPathResult</code> interface.
286N/A * @param result The <code>result</code> specifies a specific result
286N/A * object which may be reused and returned by this method. If this is
286N/A * specified as <code>null</code>or the implementation does not reuse
286N/A * the specified result, a new result object will be constructed and
286N/A * returned.For XPath 1.0 results, this object will be of type
286N/A * <code>XPathResult</code>.
286N/A * @return The result of the evaluation of the XPath expression.For XPath
286N/A * 1.0 results, this object will be of type <code>XPathResult</code>.
286N/A * @exception XPathException
286N/A * INVALID_EXPRESSION_ERR: Raised if the expression is not legal
286N/A * according to the rules of the <code>XPathEvaluator</code>i
286N/A * <br>TYPE_ERR: Raised if the result cannot be converted to return the
286N/A * specified type.
286N/A * @exception DOMException
286N/A * NAMESPACE_ERR: Raised if the expression contains namespace prefixes
286N/A * which cannot be resolved by the specified
286N/A * <code>XPathNSResolver</code>.
286N/A * <br>WRONG_DOCUMENT_ERR: The Node is from a document that is not
286N/A * supported by this <code>XPathEvaluator</code>.
286N/A * <br>NOT_SUPPORTED_ERR: The Node is not a type permitted as an XPath
286N/A * context node or the request type is not permitted by this
286N/A * <code>XPathEvaluator</code>.
286N/A */
286N/A public Object evaluate(String expression,
286N/A Node contextNode,
286N/A XPathNSResolver resolver,
286N/A short type,
286N/A Object result)
286N/A throws XPathException, DOMException;
286N/A
286N/A}