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