00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(SIMPLENODELOCATOR_HEADER_GUARD_1357924680) 00058 #define SIMPLENODELOCATOR_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base header file. Must be first. 00063 #include <XPath/XPathDefinitions.hpp> 00064 00065 00066 00067 #include <XalanDOM/XalanDOMString.hpp> 00068 #include <XalanDOM/XalanNode.hpp> 00069 00070 00071 00072 #include <XPath/MutableNodeRefList.hpp> 00073 #include <XPath/XObject.hpp> 00074 #include <XPath/XPath.hpp> 00075 00076 00077 00078 class XPathExpression; 00079 00080 00081 00086 class XALAN_XPATH_EXPORT SimpleNodeLocator 00087 { 00088 public: 00089 00090 static const XObjectPtr 00091 locationPath( 00092 const XPath& xpath, 00093 XPathExecutionContext& executionContext, 00094 XalanNode& context, 00095 int opPos); 00096 00097 static XPath::eMatchScore 00098 locationPathPattern( 00099 const XPath& xpath, 00100 XPathExecutionContext& executionContext, 00101 XalanNode& context, 00102 int opPos); 00103 00104 class NodeTester 00105 { 00106 public: 00107 00108 NodeTester( 00109 const XPath& xpath, 00110 XPathExecutionContext& executionContext, 00111 int opPos, 00112 int argLen, 00113 int stepType); 00114 00115 XPath::eMatchScore 00116 operator()( 00117 const XalanNode& context, 00118 XalanNode::NodeType nodeType) const 00119 { 00120 assert(context.getNodeType() == nodeType); 00121 00122 return (this->*m_testFunction)(context, nodeType); 00123 } 00124 00125 private: 00126 00127 typedef XPath::eMatchScore (NodeTester::*MemberFunctionPtr)(const XalanNode&, XalanNode::NodeType) const; 00128 00129 00130 XPath::eMatchScore 00131 testComment( 00132 const XalanNode& context, 00133 XalanNode::NodeType nodeType) const; 00134 00135 XPath::eMatchScore 00136 testText( 00137 const XalanNode& context, 00138 XalanNode::NodeType nodeType) const; 00139 00140 XPath::eMatchScore 00141 testPI( 00142 const XalanNode& context, 00143 XalanNode::NodeType nodeType) const; 00144 00145 XPath::eMatchScore 00146 testPIName( 00147 const XalanNode& context, 00148 XalanNode::NodeType nodeType) const; 00149 00150 XPath::eMatchScore 00151 testNode( 00152 const XalanNode& context, 00153 XalanNode::NodeType nodeType) const; 00154 00155 XPath::eMatchScore 00156 testRoot( 00157 const XalanNode& context, 00158 XalanNode::NodeType nodeType) const; 00159 00160 XPath::eMatchScore 00161 testAttributeNCName( 00162 const XalanNode& context, 00163 XalanNode::NodeType nodeType) const; 00164 00165 XPath::eMatchScore 00166 testAttributeQName( 00167 const XalanNode& context, 00168 XalanNode::NodeType nodeType) const; 00169 00170 XPath::eMatchScore 00171 testAttributeNamespaceOnly( 00172 const XalanNode& context, 00173 XalanNode::NodeType nodeType) const; 00174 00175 XPath::eMatchScore 00176 testAttributeTotallyWild( 00177 const XalanNode& context, 00178 XalanNode::NodeType nodeType) const; 00179 00180 XPath::eMatchScore 00181 testElementNCName( 00182 const XalanNode& context, 00183 XalanNode::NodeType nodeType) const; 00184 00185 XPath::eMatchScore 00186 testElementQName( 00187 const XalanNode& context, 00188 XalanNode::NodeType nodeType) const; 00189 00190 XPath::eMatchScore 00191 testElementNamespaceOnly( 00192 const XalanNode& context, 00193 XalanNode::NodeType nodeType) const; 00194 00195 XPath::eMatchScore 00196 testElementTotallyWild( 00197 const XalanNode& context, 00198 XalanNode::NodeType nodeType) const; 00199 00200 XPath::eMatchScore 00201 testNamespaceNCName( 00202 const XalanNode& context, 00203 XalanNode::NodeType nodeType) const; 00204 00205 XPath::eMatchScore 00206 testNamespaceTotallyWild( 00207 const XalanNode& context, 00208 XalanNode::NodeType nodeType) const; 00209 00210 XPath::eMatchScore 00211 testDefault( 00212 const XalanNode& context, 00213 XalanNode::NodeType nodeType) const; 00214 00215 bool 00216 matchLocalName(const XalanNode& context) const; 00217 00218 bool 00219 matchNamespaceURI(const XalanNode& context) const; 00220 00221 bool 00222 matchLocalNameAndNamespaceURI(const XalanNode& context) const; 00223 00224 bool 00225 matchNamespace(const XalanNode& context) const; 00226 00227 bool 00228 shouldStripSourceNode(const XalanNode& context) const; 00229 00230 // Data members... 00231 XPathExecutionContext& m_executionContext; 00232 00233 const XalanDOMString* m_targetNamespace; 00234 00235 const XalanDOMString* m_targetLocalName; 00236 00237 MemberFunctionPtr m_testFunction; 00238 }; 00239 00240 protected: 00241 00242 static void 00243 step( 00244 const XPath& xpath, 00245 XPathExecutionContext& executionContext, 00246 XalanNode* context, 00247 int opPos, 00248 MutableNodeRefList& queryResults); 00249 00260 static XalanNode* 00261 stepPattern( 00262 const XPath& xpath, 00263 XPathExecutionContext& executionContext, 00264 XalanNode* context, 00265 int opPos, 00266 XPath::eMatchScore& scoreHolder); 00267 00268 static int 00269 findNodeSet( 00270 const XPath& xpath, 00271 XPathExecutionContext& executionContext, 00272 XalanNode* context, 00273 int opPos, 00274 int stepType, 00275 MutableNodeRefList& subQueryResults); 00276 00277 static int 00278 findRoot( 00279 const XPath& xpath, 00280 XPathExecutionContext& executionContext, 00281 XalanNode* context, 00282 int opPos, 00283 int stepType, 00284 MutableNodeRefList& subQueryResults); 00285 00286 static int 00287 findParent( 00288 const XPath& xpath, 00289 XPathExecutionContext& executionContext, 00290 XalanNode* context, 00291 int opPos, 00292 int stepType, 00293 MutableNodeRefList& subQueryResults); 00294 00295 static int 00296 findSelf( 00297 const XPath& xpath, 00298 XPathExecutionContext& executionContext, 00299 XalanNode* context, 00300 int opPos, 00301 int stepType, 00302 MutableNodeRefList& subQueryResults); 00303 00304 static int 00305 findAncestors( 00306 const XPath& xpath, 00307 XPathExecutionContext& executionContext, 00308 XalanNode* context, 00309 int opPos, 00310 int stepType, 00311 MutableNodeRefList& subQueryResults); 00312 00313 static int 00314 findAncestorsOrSelf( 00315 const XPath& xpath, 00316 XPathExecutionContext& executionContext, 00317 XalanNode* context, 00318 int opPos, 00319 int stepType, 00320 MutableNodeRefList& subQueryResults); 00321 00322 static int 00323 findAttributes( 00324 const XPath& xpath, 00325 XPathExecutionContext& executionContext, 00326 XalanNode* context, 00327 int opPos, 00328 int stepType, 00329 MutableNodeRefList& subQueryResults); 00330 00331 static int 00332 findChildren( 00333 const XPath& xpath, 00334 XPathExecutionContext& executionContext, 00335 XalanNode* context, 00336 int opPos, 00337 int stepType, 00338 MutableNodeRefList& subQueryResults); 00339 00340 static int 00341 findDescendants( 00342 const XPath& xpath, 00343 XPathExecutionContext& executionContext, 00344 XalanNode* context, 00345 int opPos, 00346 int stepType, 00347 MutableNodeRefList& subQueryResults); 00348 00349 static int 00350 findFollowing( 00351 const XPath& xpath, 00352 XPathExecutionContext& executionContext, 00353 XalanNode* context, 00354 int opPos, 00355 int stepType, 00356 MutableNodeRefList& subQueryResults); 00357 00358 static int 00359 findFollowingSiblings( 00360 const XPath& xpath, 00361 XPathExecutionContext& executionContext, 00362 XalanNode* context, 00363 int opPos, 00364 int stepType, 00365 MutableNodeRefList& subQueryResults); 00366 00367 static int 00368 findPreceeding( 00369 const XPath& xpath, 00370 XPathExecutionContext& executionContext, 00371 XalanNode* context, 00372 int opPos, 00373 int stepType, 00374 MutableNodeRefList& subQueryResults); 00375 00376 static int 00377 findPreceedingSiblings( 00378 const XPath& xpath, 00379 XPathExecutionContext& executionContext, 00380 XalanNode* context, 00381 int opPos, 00382 int stepType, 00383 MutableNodeRefList& subQueryResults); 00384 00385 static int 00386 findNamespace( 00387 const XPath& xpath, 00388 XPathExecutionContext& executionContext, 00389 XalanNode* context, 00390 int opPos, 00391 int stepType, 00392 MutableNodeRefList& subQueryResults); 00393 00394 static int 00395 findNodesOnUnknownAxis( 00396 const XPath& xpath, 00397 XPathExecutionContext& executionContext, 00398 XalanNode* context, 00399 int opPos, 00400 int stepType, 00401 MutableNodeRefList& subQueryResults); 00402 00403 static XPath::eMatchScore 00404 nodeTest( 00405 const XPath& xpath, 00406 XPathExecutionContext& executionContext, 00407 XalanNode* context, 00408 XalanNode::NodeType nodeType, 00409 int opPos, 00410 int argLen, 00411 int stepType); 00412 00413 static void 00414 predicates( 00415 const XPath& xpath, 00416 XPathExecutionContext& executionContext, 00417 XalanNode* context, 00418 int opPos, 00419 MutableNodeRefList& subQueryResults, 00420 int& endPredicatesPos); 00421 00422 static XPath::eMatchScore 00423 handleFoundIndex( 00424 const XPath& xpath, 00425 XPathExecutionContext& executionContext, 00426 XalanNode* localContext, 00427 int startOpPos); 00428 00429 private: 00430 00431 // Not defined... 00432 SimpleNodeLocator(); 00433 00434 ~SimpleNodeLocator(); 00435 00436 00437 static const XalanDOMString s_emptyString; 00438 }; 00439 00440 00441 00442 #endif // SIMPLENODELOCATOR_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.1 |
|