source: icXML/icXML-devel/src/xercesc/dom/DOMXPathEvaluator.hpp

Last change on this file was 2722, checked in by cameron, 7 years ago

Original Xerces files with import mods for icxercesc

File size: 8.9 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/*
19 * $Id: DOMXPathEvaluator.hpp 698579 2008-09-24 14:13:08Z borisk $
20 */
21
22#if !defined(XERCESC_INCLUDE_GUARD_DOMXPATHEVALUATOR_HPP)
23#define XERCESC_INCLUDE_GUARD_DOMXPATHEVALUATOR_HPP
24
25#include <xercesc/util/XercesDefs.hpp>
26#include <xercesc/dom/DOMXPathResult.hpp>
27
28XERCES_CPP_NAMESPACE_BEGIN
29
30class DOMXPathNSResolver;
31class DOMXPathExpression;
32class DOMNode;
33
34/**
35 * The evaluation of XPath expressions is provided by <code>DOMXPathEvaluator</code>.
36 * In a DOM implementation which supports the XPath feature, the <code>DOMXPathEvaluator</code>
37 * interface will be implemented on the same object which implements the Document interface permitting
38 * it to be obtained by casting or by using the DOM Level 3 getFeature method. In this case the
39 * implementation obtained from the Document supports the XPath DOM module and is compatible
40 * with the XPath 1.0 specification.
41 * Evaluation of expressions with specialized extension functions or variables may not
42 * work in all implementations and is, therefore, not portable. XPathEvaluator implementations
43 * may be available from other sources that could provide specific support for specialized extension
44 * functions or variables as would be defined by other specifications.
45 * @since DOM Level 3
46 */
47class CDOM_EXPORT DOMXPathEvaluator
48{
49
50protected:
51    // -----------------------------------------------------------------------
52    //  Hidden constructors
53    // -----------------------------------------------------------------------
54    /** @name Hidden constructors */
55    //@{
56    DOMXPathEvaluator() {};
57    //@}
58
59private:
60    // -----------------------------------------------------------------------
61    // Unimplemented constructors and operators
62    // -----------------------------------------------------------------------
63    /** @name Unimplemented constructors and operators */
64    //@{
65    DOMXPathEvaluator(const DOMXPathEvaluator &);
66    DOMXPathEvaluator& operator = (const  DOMXPathEvaluator&);
67    //@}
68
69public:
70    // -----------------------------------------------------------------------
71    //  All constructors are hidden, just the destructor is available
72    // -----------------------------------------------------------------------
73    /** @name Destructor */
74    //@{
75    /**
76     * Destructor
77     *
78     */
79    virtual ~DOMXPathEvaluator() {};
80    //@}
81
82    // -----------------------------------------------------------------------
83    // Virtual DOMXPathEvaluator interface
84    // -----------------------------------------------------------------------
85    /** @name Functions introduced in DOM Level 3 */
86    //@{
87
88    /**
89     * Creates a parsed XPath expression with resolved namespaces. This is useful
90     * when an expression will be reused in an application since it makes it
91     * possible to compile the expression string into a more efficient internal
92     * form and preresolve all namespace prefixes which occur within the expression.
93     * @param expression of type XMLCh - The XPath expression string to be parsed.
94     * @param resolver of type <code>XPathNSResolver</code> - The resolver permits
95     * translation of all prefixes, including the xml namespace prefix, within the XPath expression
96     * into appropriate namespace URIs. If this is specified as null, any namespace
97     * prefix within the expression will result in <code>DOMException</code> being thrown with the
98     * code NAMESPACE_ERR.
99     * @return <code>DOMXPathExpression</code> The compiled form of the XPath expression.
100     * @exception <code>DOMXPathException</code>
101     * INVALID_EXPRESSION_ERR: Raised if the expression is not legal according to the
102     * rules of the <code>DOMXPathEvaluator</code>.
103     * @exception DOMException
104     * NAMESPACE_ERR: Raised if the expression contains namespace prefixes which cannot
105     * be resolved by the specified <code>XPathNSResolver</code>.
106     * @since DOM Level 3
107     */
108    virtual DOMXPathExpression* createExpression(const XMLCh *expression,
109                                                 const DOMXPathNSResolver *resolver) = 0;
110
111
112    /** Adapts any DOM node to resolve namespaces so that an XPath expression can be
113     * easily evaluated relative to the context of the node where it appeared within
114     * the document. This adapter works like the DOM Level 3 method lookupNamespaceURI
115     * on nodes in resolving the namespaceURI from a given prefix using the current
116     * information available in the node's hierarchy at the time lookupNamespaceURI
117     * is called. also correctly resolving the implicit xml prefix.
118     * @param nodeResolver of type <code>DOMNode</code> The node to be used as a context
119     * for namespace resolution. If this parameter is null, an unpopulated
120     * <code>DOMXPathNSResolver</code> is returned, which can be populated using the
121     * Xerces-C extension <code>DOMXPathNSResolver::addNamespaceBinding()</code>.
122     * @return <code>DOMXPathNSResolver</code> The object which resolves namespaces
123     * with respect to the definitions in scope for the specified node.
124     */
125    virtual DOMXPathNSResolver* createNSResolver(const DOMNode *nodeResolver) = 0;
126
127
128    /**
129     * Evaluates an XPath expression string and returns a result of the specified
130     * type if possible.
131     * @param expression of type XMLCh The XPath expression string to be parsed
132     * and evaluated.
133     * @param contextNode of type <code>DOMNode</code> The context is context node
134     * for the evaluation
135     * of this XPath expression. If the <code>DOMXPathEvaluator</code> was obtained by
136     * casting the <code>DOMDocument</code> then this must be owned by the same
137     * document and must be a <code>DOMDocument</code>, <code>DOMElement</code>,
138     * <code>DOMAttribute</code>, <code>DOMText</code>, <code>DOMCDATASection</code>,
139     * <code>DOMComment</code>, <code>DOMProcessingInstruction</code>, or
140     * <code>XPathNamespace</code> node. If the context node is a <code>DOMText</code> or
141     * a <code>DOMCDATASection</code>, then the context is interpreted as the whole
142     * logical text node as seen by XPath, unless the node is empty in which case it
143     * may not serve as the XPath context.
144     * @param resolver of type <code>XPathNSResolver</code> The resolver permits
145     * translation of all prefixes, including the xml namespace prefix, within
146     * the XPath expression into appropriate namespace URIs. If this is specified
147     * as null, any namespace prefix within the expression will result in
148     * <code>DOMException</code> being thrown with the code NAMESPACE_ERR.
149     * @param type - If a specific type is specified, then
150     * the result will be returned as the corresponding type. This must be one
151     * of the codes of the <code>DOMXPathResult</code> interface.
152     * @param result of type DOMXPathResult* - The result specifies a specific result object
153     * which may be reused and returned by this method. If this is specified as
154     * null or the implementation does not reuse the specified result, a new result
155     * object will be constructed and returned.
156     * @return DOMXPathResult* The result of the evaluation of the XPath expression.
157     * @exception <code>DOMXPathException</code>
158     * INVALID_EXPRESSION_ERR: Raised if the expression is not legal
159     * according to the rules of the <code>DOMXPathEvaluator</code>
160     * TYPE_ERR: Raised if the result cannot be converted to return the specified type.
161     * @exception <code>DOMException</code>
162     * NAMESPACE_ERR: Raised if the expression contains namespace prefixes
163     * which cannot be resolved by the specified <code>XPathNSResolver</code>.
164     * WRONG_DOCUMENT_ERR: The DOMNode is from a document that is not supported
165     * by this <code>DOMXPathEvaluator</code>.
166     * NOT_SUPPORTED_ERR: The DOMNode is not a type permitted as an XPath context
167     * node or the request type is not permitted by this <code>DOMXPathEvaluator</code>.
168     */
169    virtual DOMXPathResult* evaluate(const XMLCh *expression,
170                                     const DOMNode *contextNode,
171                                     const DOMXPathNSResolver *resolver,
172                                     DOMXPathResult::ResultType type,
173                                     DOMXPathResult* result) = 0;
174
175    //@}
176};
177
178XERCES_CPP_NAMESPACE_END
179
180#endif
Note: See TracBrowser for help on using the repository browser.