source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/dom/DOMXPathEvaluator.hpp @ 2674

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