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
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
19
* $Id: XPathMatcher.hpp 679382 2008-07-24 12:09:39Z amassari $
22
#if !defined(XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP)
23
#define XERCESC_INCLUDE_GUARD_XPATHMATCHER_HPP
26
// ---------------------------------------------------------------------------
28
// ---------------------------------------------------------------------------
29
#include <xercesc/util/ValueStackOf.hpp>
30
#include <xercesc/util/RefVectorOf.hpp>
31
#include <xercesc/framework/XMLBuffer.hpp>
33
XERCES_CPP_NAMESPACE_BEGIN
35
// ---------------------------------------------------------------------------
36
// Forward Declaration
37
// ---------------------------------------------------------------------------
40
class IdentityConstraint;
41
class DatatypeValidator;
43
class XercesLocationPath;
48
class VALIDATORS_EXPORT XPathMatcher : public XMemory
51
// -----------------------------------------------------------------------
52
// Constructors/Destructor
53
// -----------------------------------------------------------------------
54
XPathMatcher(XercesXPath* const xpath,
55
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
56
XPathMatcher(XercesXPath* const xpath,
57
IdentityConstraint* const ic,
58
MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
59
virtual ~XPathMatcher();
61
// -----------------------------------------------------------------------
63
// -----------------------------------------------------------------------
64
IdentityConstraint* getIdentityConstraint() const { return fIdentityConstraint; }
65
MemoryManager* getMemoryManager() const { return fMemoryManager; }
67
// -----------------------------------------------------------------------
69
// -----------------------------------------------------------------------
71
* Returns true if XPath has been matched.
73
unsigned char isMatched();
74
virtual int getInitialDepth() const;
76
// -----------------------------------------------------------------------
77
// XMLDocumentHandler methods
78
// -----------------------------------------------------------------------
79
virtual void startDocumentFragment();
80
virtual void startElement(const XMLElementDecl& elemDecl,
81
const unsigned int urlId,
82
const XMLCh* const elemPrefix,
83
const RefVectorOf<XMLAttr>& attrList,
84
const XMLSize_t attrCount);
85
virtual void endElement(const XMLElementDecl& elemDecl,
86
const XMLCh* const elemContent);
90
XP_MATCHED = 1 // matched any way
91
, XP_MATCHED_A = 3 // matched on the attribute axis
92
, XP_MATCHED_D = 5 // matched on the descendant-or-self axixs
93
, XP_MATCHED_DP = 13 // matched some previous (ancestor) node on the
94
// descendant-or-self-axis, but not this node
99
// -----------------------------------------------------------------------
101
// -----------------------------------------------------------------------
103
* This method is called when the XPath handler matches the XPath
104
* expression. Subclasses can override this method to provide default
105
* handling upon a match.
107
virtual void matched(const XMLCh* const content,
108
DatatypeValidator* const dv, const bool isNil);
110
bool matches(const XercesNodeTest* nodeTest, const QName* qName);
113
// -----------------------------------------------------------------------
114
// Unimplemented constructors and operators
115
// -----------------------------------------------------------------------
116
XPathMatcher(const XPathMatcher&);
117
XPathMatcher& operator=(const XPathMatcher&);
119
// -----------------------------------------------------------------------
121
// -----------------------------------------------------------------------
122
void init(XercesXPath* const xpath);
125
// -----------------------------------------------------------------------
129
// Indicates whether XPath has been matched or not
132
// Indicates whether matching is successful for the given xpath
136
// Stores current step.
139
// Integer stack of step indexes.
143
// XPath location path, and its size.
145
// fIdentityConstraint
146
// The identity constraint we're the matcher for. Only used for
149
// -----------------------------------------------------------------------
150
XMLSize_t fLocationPathSize;
151
unsigned char* fMatched;
152
XMLSize_t* fNoMatchDepth;
153
XMLSize_t* fCurrentStep;
154
RefVectorOf<ValueStackOf<XMLSize_t> >* fStepIndexes;
155
RefVectorOf<XercesLocationPath>* fLocationPaths;
156
IdentityConstraint* fIdentityConstraint;
157
MemoryManager* fMemoryManager;
160
// ---------------------------------------------------------------------------
161
// XPathMatcher: Helper methods
162
// ---------------------------------------------------------------------------
163
inline void XPathMatcher::cleanUp() {
165
fMemoryManager->deallocate(fMatched);//delete [] fMatched;
166
fMemoryManager->deallocate(fNoMatchDepth);//delete [] fNoMatchDepth;
167
fMemoryManager->deallocate(fCurrentStep);//delete [] fCurrentStep;
171
XERCES_CPP_NAMESPACE_END
176
* End of file XPathMatcher.hpp