Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


XPath.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XPATH_HEADER_GUARD_1357924680)
19 #define XPATH_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base header file. Must be first.
25 
26 
27 
29 
30 
31 
33 
34 
35 
36 // Base class header files...
38 
39 
40 
45 
46 
47 
48 XALAN_DECLARE_XERCES_CLASS(Locator)
49 
50 
51 
52 XALAN_CPP_NAMESPACE_BEGIN
53 
54 
55 
56 class PrefixResolver;
57 class XObject;
58 class XalanElement;
59 class XalanNode;
61 
62 
63 
65 {
66 public:
67 
68  typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType;
69 
76 
77 
78  static const XalanDOMChar PSEUDONAME_ANY[];
79  static const XalanDOMChar PSEUDONAME_ROOT[];
80  static const XalanDOMChar PSEUDONAME_TEXT[];
81  static const XalanDOMChar PSEUDONAME_COMMENT[];
82  static const XalanDOMChar PSEUDONAME_PI[];
83  static const XalanDOMChar PSEUDONAME_OTHER[];
84  static const XalanDOMChar PSEUDONAME_NODE[];
85 
87  {
92  eMatchScoreOther
93  };
94 
95  class TargetData
96  {
97  public:
98 
99  enum eTargetType { eAttribute, eElement, eAny, eOther };
100 
102  m_string(0),
103  m_priority(eMatchScoreNone),
104  m_targetType(eOther)
105  {
106  }
107 
109  const XalanDOMChar* theString,
110  eMatchScore thePriority,
111  eTargetType theTargetType) :
112  m_string(theString),
113  m_priority(thePriority),
114  m_targetType(theTargetType)
115  {
116  }
117 
118  const XalanDOMChar*
119  getString() const
120  {
121  return m_string;
122  }
123 
126  {
127  return m_priority;
128  }
129 
132  {
133  return m_targetType;
134  }
135 
136  private:
137 
138  const XalanDOMChar* m_string;
139 
140  eMatchScore m_priority;
141 
142  eTargetType m_targetType;
143  };
144 
146 
147  /**
148  * Perform static initialization. See class XPathInit.
149  */
150  static void
151  initialize(MemoryManager& theManager);
152 
153  /**
154  * Perform static shut down. See class XPathInit.
155  */
156  static void
157  terminate();
158 
159  /**
160  * Construct an XPath.
161  *
162  * @param theLocator The applicable Locator, if any.
163  */
164  explicit
165  XPath(
166  MemoryManager& theManager,
167  const Locator* theLocator = 0);
168 
169  static XPath*
170  create(
171  MemoryManager& theManager,
172  const Locator* theLocator = 0);
173 
174  MemoryManager&
176  {
177  return m_expression.getMemoryManager();
178  }
179 
180  ~XPath();
181 
182  /**
183  * Shrink internal tables.
184  */
185  void
187  {
188  m_expression.shrink();
189  }
190 
191  /**
192  * Execute the XPath from the provided context.
193  *
194  * @param context current source tree context node, which must not be 0
195  * @param prefixResolver prefix resolver to use
196  * @param executionContext current execution context
197  * @return smart-pointer to result XObject
198  */
199  const XObjectPtr
200  execute(
201  XalanNode* context,
202  const PrefixResolver& prefixResolver,
203  XPathExecutionContext& executionContext) const;
204 
205  /**
206  * Execute the XPath from the provided context.
207  *
208  * @param context current source tree context node, which must not be 0
209  * @param prefixResolver prefix resolver to use
210  * @param executionContext current execution context
211  * @param result the boolean result
212  */
213  void
214  execute(
215  XalanNode* context,
216  const PrefixResolver& prefixResolver,
217  XPathExecutionContext& executionContext,
218  bool& result) const;
219 
220  /**
221  * Execute the XPath from the provided context.
222  *
223  * @param context current source tree context node, which must not be 0
224  * @param prefixResolver prefix resolver to use
225  * @param executionContext current execution context
226  * @param result the numeric result
227  */
228  void
229  execute(
230  XalanNode* context,
231  const PrefixResolver& prefixResolver,
232  XPathExecutionContext& executionContext,
233  double& result) const;
234 
235  /**
236  * Execute the XPath from the provided context. The
237  * result is appended to the supplied string.
238  *
239  * @param context current source tree context node, which must not be 0
240  * @param prefixResolver prefix resolver to use
241  * @param executionContext current execution context
242  * @param result the string result
243  */
244  void
245  execute(
246  XalanNode* context,
247  const PrefixResolver& prefixResolver,
248  XPathExecutionContext& executionContext,
249  XalanDOMString& result) const;
250 
251  typedef void (FormatterListener::*MemberFunctionPtr)(const XMLCh* const, const FormatterListener::size_type);
252 
253  /**
254  * Execute the XPath from the provided context.
255  *
256  * @param context current source tree context node, which must not be 0
257  * @param prefixResolver prefix resolver to use
258  * @param executionContext current execution context
259  * @param formatterListener the FormatterListener instance to receive the result
260  * @param function A pointer to the member function of FormatterListener to call
261  */
262  void
263  execute(
264  XalanNode* context,
265  const PrefixResolver& prefixResolver,
266  XPathExecutionContext& executionContext,
267  FormatterListener& formatterListener,
268  MemberFunctionPtr function) const;
269 
270  /**
271  * Execute the XPath from the provided context. Normally,
272  * the expression will be evaluated and the result placed
273  * in the parameter result. However, some cases (such as
274  * the evalution of a variable) could result in the copying
275  * of a node-set, which is extremely expensive. In that
276  * case, the return value will contain the result of the
277  * evaluation. If the call to XObject::null() on the return
278  * value is true, that indicates the value was executed
279  * directly into the parameter. Otherwise, the parameter
280  * will be empty, and the result will be in the XObject
281  * instance returned.
282  *
283  * @param context current source tree context node, which must not be 0
284  * @param prefixResolver prefix resolver to use
285  * @param executionContext current execution context
286  * @param result the node-set result
287  * @return the node-set result, if the result was not returned in the parameter
288  */
289  const XObjectPtr
290  execute(
291  XalanNode* context,
292  const PrefixResolver& prefixResolver,
293  XPathExecutionContext& executionContext,
294  MutableNodeRefList& result) const;
295 
296  /**
297  * Execute the XPath from the provided context.
298  *
299  * @param context current source tree context node, which must not be 0
300  * @param prefixResolver prefix resolver to use
301  * @param contextNodeList node list for current context
302  * @param executionContext current execution context
303  * @return smart-pointer to result XObject
304  */
305  const XObjectPtr
307  XalanNode* context,
308  const PrefixResolver& prefixResolver,
309  const NodeRefListBase& contextNodeList,
310  XPathExecutionContext& executionContext) const
311  {
312  // Push and pop the context node list...
314  executionContext,
315  contextNodeList);
316 
317  return execute(context, prefixResolver, executionContext);
318  }
319 
320  /**
321  * Execute the XPath from the provided context.
322  *
323  * @param context current source tree context node, which must not be 0
324  * @param prefixResolver prefix resolver to use
325  * @param contextNodeList node list for current context
326  * @param executionContext current execution context
327  * @param result the boolean result
328  */
329  void
331  XalanNode* context,
332  const PrefixResolver& prefixResolver,
333  const NodeRefListBase& contextNodeList,
334  XPathExecutionContext& executionContext,
335  bool& result) const
336  {
337  // Push and pop the context node list...
339  executionContext,
340  contextNodeList);
341 
342  execute(context, prefixResolver, executionContext, result);
343  }
344 
345  /**
346  * Execute the XPath from the provided context.
347  *
348  * @param context current source tree context node, which must not be 0
349  * @param prefixResolver prefix resolver to use
350  * @param contextNodeList node list for current context
351  * @param executionContext current execution context
352  * @param result the numeric result
353  */
354  void
356  XalanNode* context,
357  const PrefixResolver& prefixResolver,
358  const NodeRefListBase& contextNodeList,
359  XPathExecutionContext& executionContext,
360  double& result) const
361  {
362  // Push and pop the context node list...
364  executionContext,
365  contextNodeList);
366 
367  execute(context, prefixResolver, executionContext, result);
368  }
369 
370  /**
371  * Execute the XPath from the provided context. The
372  * result is appended to the supplied string.
373  *
374  * @param context current source tree context node, which must not be 0
375  * @param prefixResolver prefix resolver to use
376  * @param contextNodeList node list for current context
377  * @param executionContext current execution context
378  * @param result the string result
379  */
380  void
382  XalanNode* context,
383  const PrefixResolver& prefixResolver,
384  const NodeRefListBase& contextNodeList,
385  XPathExecutionContext& executionContext,
386  XalanDOMString& result) const
387  {
388  // Push and pop the context node list...
390  executionContext,
391  contextNodeList);
392 
393  execute(context, prefixResolver, executionContext, result);
394  }
395 
396  /**
397  * Execute the XPath from the provided context.
398  *
399  * @param context current source tree context node, which must not be 0
400  * @param prefixResolver prefix resolver to use
401  * @param contextNodeList node list for current context
402  * @param executionContext current execution context
403  * @param formatterListener the FormatterListener instance to receive the result
404  * @param function A pointer to the member function of FormatterListener to call
405  */
406  void
408  XalanNode* context,
409  const PrefixResolver& prefixResolver,
410  const NodeRefListBase& contextNodeList,
411  XPathExecutionContext& executionContext,
412  FormatterListener& formatterListener,
413  MemberFunctionPtr function) const
414  {
415  // Push and pop the context node list...
417  executionContext,
418  contextNodeList);
419 
420  execute(context, prefixResolver, executionContext, formatterListener, function);
421  }
422 
423  /**
424  * Execute the XPath from the provided context. Normally,
425  * the expression will be evaluated and the result placed
426  * in the parameter result. However, some cases (such as
427  * the evalution of a variable) could result in the copying
428  * of a node-set, which is extremely expensive. In that
429  * case, the return value will contain the result of the
430  * evaluation. If the call to XObject::null() on the return
431  * value is true, that indicates the value was executed
432  * directly into the parameter. Otherwise, the parameter
433  * will be empty, and the result will be in the XObject
434  * instance returned.
435  *
436  * @param context current source tree context node, which must not be 0
437  * @param prefixResolver prefix resolver to use
438  * @param contextNodeList node list for current context
439  * @param executionContext current execution context
440  * @param result the result as a set of nodes
441  * @return the node-set result, if the result was not returned in the parameter
442  */
443  const XObjectPtr
445  XalanNode* context,
446  const PrefixResolver& prefixResolver,
447  const NodeRefListBase& contextNodeList,
448  XPathExecutionContext& executionContext,
449  MutableNodeRefList& result) const
450  {
451  // Push and pop the context node list...
453  executionContext,
454  contextNodeList);
455 
456  return execute(context, prefixResolver, executionContext, result);
457  }
458 
459  /**
460  * Execute the XPath from the provided context.
461  *
462  * The prefix resolver and current node must already
463  * be set execution context, and must not be 0.
464  *
465  * @param executionContext current execution context
466  * @return smart-pointer to result XObject
467  */
468  const XObjectPtr
469  execute(XPathExecutionContext& executionContext) const
470  {
471  assert(executionContext.getCurrentNode() != 0);
472  assert(executionContext.getPrefixResolver() != 0);
473 
474  return executeMore(
475  executionContext.getCurrentNode(),
476  getInitialOpCodePosition(),
477  executionContext);
478  }
479 
480  /**
481  * Execute the XPath from the provided context.
482  *
483  * The prefix resolver and current node must already
484  * be set execution context, and must not be 0.
485  *
486  * @param executionContext current execution context
487  * @param result the boolean result
488  */
489  void
491  XPathExecutionContext& executionContext,
492  bool& result) const
493  {
494  assert(executionContext.getCurrentNode() != 0);
495  assert(executionContext.getPrefixResolver() != 0);
496 
497  executeMore(
498  executionContext.getCurrentNode(),
499  getInitialOpCodePosition(),
500  executionContext,
501  result);
502  }
503 
504  /**
505  * Execute the XPath from the provided context.
506  *
507  * The prefix resolver must already be set in the
508  * execution context.
509  *
510  * @param executionContext current execution context
511  * @param result the numeric result
512  */
513  void
515  XPathExecutionContext& executionContext,
516  double& result) const
517  {
518  assert(executionContext.getCurrentNode() != 0);
519  assert(executionContext.getPrefixResolver() != 0);
520 
521  executeMore(
522  executionContext.getCurrentNode(),
523  getInitialOpCodePosition(),
524  executionContext,
525  result);
526  }
527 
528  /**
529  * Execute the XPath from the provided context. The
530  * result is appended to the supplied string.
531  *
532  * The prefix resolver and current node must already
533  * be set execution context, and must not be 0.
534  *
535  * @param executionContext current execution context
536  * @param result the string result
537  */
538  void
540  XPathExecutionContext& executionContext,
541  XalanDOMString& result) const
542  {
543  assert(executionContext.getCurrentNode() != 0);
544  assert(executionContext.getPrefixResolver() != 0);
545 
546  executeMore(
547  executionContext.getCurrentNode(),
548  getInitialOpCodePosition(),
549  executionContext,
550  result);
551  }
552 
553  /**
554  * Execute the XPath from the provided context.
555  *
556  * The prefix resolver and current node must already
557  * be set execution context, and must not be 0.
558  *
559  * @param executionContext current execution context
560  * @param formatterListener the FormatterListener instance to receive the result
561  * @param function A pointer to the member function of FormatterListener to call
562  */
563  void
565  XPathExecutionContext& executionContext,
566  FormatterListener& formatterListener,
567  MemberFunctionPtr function) const
568  {
569  assert(executionContext.getCurrentNode() != 0);
570  assert(executionContext.getPrefixResolver() != 0);
571 
572  executeMore(
573  executionContext.getCurrentNode(),
574  getInitialOpCodePosition(),
575  executionContext,
576  formatterListener,
577  function);
578  }
579 
580  /**
581  * Execute the XPath from the provided context. Normally,
582  * the expression will be evaluated and the result placed
583  * in the parameter result. However, some cases (such as
584  * the evalution of a variable) could result in the copying
585  * of a node-set, which is extremely expensive. In that
586  * case, the return value will contain the result of the
587  * evaluation. If the call to XObject::null() on the return
588  * value is true, that indicates the value was executed
589  * directly into the parameter. Otherwise, the parameter
590  * will be empty, and the result will be in the XObject
591  * instance returned.
592  *
593  * The prefix resolver and current node must already
594  * be set execution context, and must not be 0.
595  *
596  * @param executionContext current execution context
597  * @param result A node list for the result. This may or may not contain the actual result.
598  * @return the node-set result, if the result was not returned in the parameter
599  */
600  const XObjectPtr
602  XPathExecutionContext& executionContext,
603  MutableNodeRefList& result) const
604  {
605  assert(executionContext.getCurrentNode() != 0);
606  assert(executionContext.getPrefixResolver() != 0);
607 
608  return executeMore(
609  executionContext.getCurrentNode(),
610  getInitialOpCodePosition(),
611  executionContext,
612  result);
613  }
614 
615  /**
616  * Execute the XPath from the provided context.
617  *
618  * The current node must already be set execution context,
619  * and must not be 0.
620  *
621  * @param executionContext current execution context
622  * @param prefixResolver prefix resolver to use
623  * @return smart-pointer to result XObject
624  */
625  const XObjectPtr
627  const PrefixResolver& prefixResolver,
628  XPathExecutionContext& executionContext) const
629  {
630  assert(executionContext.getCurrentNode() != 0);
631 
632  // Push and pop the PrefixResolver...
633  const PrefixResolverSetAndRestore theResolverSetAndRestore(
634  executionContext,
635  &prefixResolver);
636 
637  return executeMore(
638  executionContext.getCurrentNode(),
639  getInitialOpCodePosition(),
640  executionContext);
641  }
642 
643  /**
644  * Execute the XPath from the provided context.
645  *
646  * The current node must already be set execution context,
647  * and must not be 0.
648  *
649  * @param executionContext current execution context
650  * @param prefixResolver prefix resolver to use
651  * @param result the boolean result
652  */
653  void
655  const PrefixResolver& prefixResolver,
656  XPathExecutionContext& executionContext,
657  bool& result) const
658  {
659  assert(executionContext.getCurrentNode() != 0);
660 
661  // Push and pop the PrefixResolver...
662  const PrefixResolverSetAndRestore theResolverSetAndRestore(
663  executionContext,
664  &prefixResolver);
665 
666  executeMore(
667  executionContext.getCurrentNode(),
668  getInitialOpCodePosition(),
669  executionContext,
670  result);
671  }
672 
673  /**
674  * Execute the XPath from the provided context.
675  *
676  * The current node must already be set execution context,
677  * and must not be 0.
678  *
679  * @param executionContext current execution context
680  * @param prefixResolver prefix resolver to use
681  * @param result the numeric result
682  */
683  void
685  const PrefixResolver& prefixResolver,
686  XPathExecutionContext& executionContext,
687  double& result) const
688  {
689  assert(executionContext.getCurrentNode() != 0);
690 
691  // Push and pop the PrefixResolver...
692  const PrefixResolverSetAndRestore theResolverSetAndRestore(
693  executionContext,
694  &prefixResolver);
695 
696  executeMore(
697  executionContext.getCurrentNode(),
698  getInitialOpCodePosition(),
699  executionContext,
700  result);
701  }
702 
703  /**
704  * Execute the XPath from the provided context. The
705  * result is appended to the supplied string.
706  *
707  * The current node must already be set execution context,
708  * and must not be 0.
709  *
710  * @param executionContext current execution context
711  * @param prefixResolver prefix resolver to use
712  * @param result the string result
713  */
714  void
716  const PrefixResolver& prefixResolver,
717  XPathExecutionContext& executionContext,
718  XalanDOMString& result) const
719  {
720  assert(executionContext.getCurrentNode() != 0);
721 
722  // Push and pop the PrefixResolver...
723  const PrefixResolverSetAndRestore theResolverSetAndRestore(
724  executionContext,
725  &prefixResolver);
726 
727  executeMore(
728  executionContext.getCurrentNode(),
729  getInitialOpCodePosition(),
730  executionContext,
731  result);
732  }
733 
734  /**
735  * Execute the XPath from the provided context.
736  *
737  * @param prefixResolver prefix resolver to use
738  * @param executionContext current execution context
739  * @param formatterListener the FormatterListener instance to receive the result
740  * @param function A pointer to the member function of FormatterListener to call
741  */
742  void
744  const PrefixResolver& prefixResolver,
745  XPathExecutionContext& executionContext,
746  FormatterListener& formatterListener,
747  MemberFunctionPtr function) const
748  {
749  assert(executionContext.getCurrentNode() != 0);
750 
751  // Push and pop the PrefixResolver...
752  const PrefixResolverSetAndRestore theResolverSetAndRestore(
753  executionContext,
754  &prefixResolver);
755 
756  executeMore(
757  executionContext.getCurrentNode(),
758  getInitialOpCodePosition(),
759  executionContext,
760  formatterListener,
761  function);
762  }
763 
764  /**
765  * Execute the XPath from the provided context. Normally,
766  * the expression will be evaluated and the result placed
767  * in the parameter result. However, some cases (such as
768  * the evalution of a variable) could result in the copying
769  * of a node-set, which is extremely expensive. In that
770  * case, the return value will contain the result of the
771  * evaluation. If the call to XObject::null() on the return
772  * value is true, that indicates the value was executed
773  * directly into the parameter. Otherwise, the parameter
774  * will be empty, and the result will be in the XObject
775  * instance returned.
776  *
777  * The current node must already be set execution context,
778  * and must not be 0.
779  *
780  * @param executionContext current execution context
781  * @param prefixResolver prefix resolver to use
782  * @param result A node list for the result. This may or may not contain the actual result.
783  * @return the node-set result, if the result was not returned in the parameter
784  */
785  XObjectPtr
787  const PrefixResolver& prefixResolver,
788  XPathExecutionContext& executionContext,
789  MutableNodeRefList& result) const
790  {
791  assert(executionContext.getCurrentNode() != 0);
792 
793  // Push and pop the PrefixResolver...
794  const PrefixResolverSetAndRestore theResolverSetAndRestore(
795  executionContext,
796  &prefixResolver);
797 
798  return executeMore(
799  executionContext.getCurrentNode(),
800  getInitialOpCodePosition(),
801  executionContext,
802  result);
803  }
804 
805  /**
806  * Retrieve a reference to the current expression.
807  *
808  * @return current expression
809  */
812  {
813  return m_expression;
814  }
815 
816  /**
817  * Retrieve a reference to the current expression.
818  *
819  * @return current expression
820  */
821  const XPathExpression&
823  {
824  return m_expression;
825  }
826 
827  static double
829  {
830  switch(score)
831  {
832  case eMatchScoreNone:
834  break;
835 
836  case eMatchScoreNodeTest:
837  return -0.5;
838  break;
839 
840  case eMatchScoreNSWild:
841  return -0.25;
842  break;
843 
844  case eMatchScoreOther:
845  return 0.5;
846  break;
847 
848  case eMatchScoreQName:
849  return 0.0;
850  break;
851  };
852 
853  assert(false);
854  return 0.0;
855  }
856 
857  /**
858  * Get the match score for the specified node.
859  *
860  * @param node The node for the score
861  * @param executionContext current execution context
862  * @return union of node-set operands
863  */
865  getMatchScore(
866  XalanNode* node,
867  XPathExecutionContext& executionContext) const;
868 
869  /**
870  * Get the match score for the specified node.
871  *
872  * @param node The node for the score
873  * @param resolver The prefix resolver
874  * @param executionContext current execution context
875  * @return union of node-set operands
876  */
878  getMatchScore(
879  XalanNode* node,
880  const PrefixResolver& resolver,
881  XPathExecutionContext& executionContext) const;
882 
883  /**
884  * Evaluate a predicate.
885  *
886  * @param context current source tree context node
887  * @param opPos current position in the Op Map
888  * @param executionContext current execution context
889  * @return pointer to either a boolean or a number
890  */
891  const XObjectPtr
893  XalanNode* context,
894  OpCodeMapPositionType opPos,
895  XPathExecutionContext& executionContext) const
896  {
897  return executeMore(context, opPos + 2, executionContext);
898  }
899 
900  /**
901  * Add the data for the target of match pattern to a vector.
902  *
903  * @param targetData The vector for the data
904  */
905  void
906  getTargetData(TargetDataVectorType& targetData) const;
907 
908  /**
909  * Install a built-in function.
910  *
911  * @param funcName unqualified name of the function
912  * @param func instance of an XPath function object
913  */
914  static void
916  const XalanDOMString& funcName,
917  const Function& func)
918  {
919  s_functions.InstallFunction(funcName,
920  func);
921  }
922 
923  /**
924  * Install a built-in function.
925  *
926  * @param funcName unqualified name of the function
927  * @param func instance of an XPath function object
928  */
929  static void
931  const XalanDOMChar* funcName,
932  const Function& func)
933  {
934  s_functions.InstallFunction(funcName,
935  func);
936  }
937 
938  /**
939  * Remove a named function from the function table.
940  *
941  * @param funcName name of function
942  * @return true if the function was found and removed.
943  */
944  static bool
946  {
947  return s_functions.UninstallFunction(funcName);
948  }
949 
950  /**
951  * Remove a named function from the function table.
952  *
953  * @param funcName name of function
954  * @return true if the function was found and removed.
955  */
956  static bool
957  uninstallFunction(const XalanDOMChar* funcName)
958  {
959  return s_functions.UninstallFunction(funcName);
960  }
961 
962  /**
963  * Whether the named function is installed in the function table.
964  *
965  * @param name of function
966  * @return true if the function has been installed
967  */
968  static bool
969  isInstalledFunction(const XalanDOMString& theFunctionName)
970  {
971  return s_functions.isInstalledFunction(theFunctionName);
972  }
973 
975 
976  /**
977  * Retrieve the table of installed functions.
978  *
979  * @return function table
980  */
981  static const FunctionTableType&
983  {
984  return s_functions;
985  }
986 
987  /**
988  * Add the names for the installed functions to a vector strings.
989  *
990  * @param theIterator vector added to
991  */
992  template<class OutputIteratorType>
993  static void
994  getInstalledFunctionNames(OutputIteratorType theIterator)
995  {
996  s_functions.getInstalledFunctionNames(theIterator);
997  }
998 
999  static void
1001  {
1002  s_functions.DestroyTable();
1003  }
1004 
1005  bool
1007  {
1008  return m_inStylesheet;
1009  }
1010 
1011  void
1012  setInStylesheet(bool fValue)
1013  {
1014  m_inStylesheet = fValue;
1015  }
1016 
1017  const Locator*
1018  getLocator() const
1019  {
1020  return m_locator;
1021  }
1022 
1023  void
1024  setLocator(const Locator* theLocator)
1025  {
1026  m_locator = theLocator;
1027  }
1028 
1030  {
1031  public:
1032 
1033  NodeTester();
1034 
1035  NodeTester(const NodeTester& theSource);
1036 
1037  NodeTester(
1038  const XPath& xpath,
1039  XPathExecutionContext& executionContext,
1040  OpCodeMapPositionType opPos,
1041  OpCodeMapValueType argLen,
1042  OpCodeMapValueType stepType);
1043 
1044  NodeTester(
1045  XPathConstructionContext& theContext,
1046  const XalanDOMString& theNameTest,
1047  const PrefixResolver& thePrefixResolver,
1048  const Locator* theLocator = 0,
1049  eMatchScore* theMatchScore = 0);
1050 
1051  NodeTester(
1052  const XalanDOMString& theNamespaceURI,
1053  const XalanDOMString& theLocalName,
1054  eMatchScore* theMatchScore = 0);
1055 
1056  eMatchScore
1058  const XalanNode& context,
1059  XalanNode::NodeType nodeType) const
1060  {
1061  assert(context.getNodeType() == nodeType);
1062 
1063  return (this->*m_testFunction)(context, nodeType);
1064  }
1065 
1066  eMatchScore
1067  operator()(const XalanElement& context) const
1068  {
1069  return (this->*m_testFunction2)(context);
1070  }
1071 
1072  NodeTester&
1073  operator=(const NodeTester& theRHS)
1074  {
1075  m_executionContext = theRHS.m_executionContext;
1076  m_targetNamespace = theRHS.m_targetNamespace;
1077  m_targetLocalName = theRHS.m_targetLocalName;
1078  m_testFunction = theRHS.m_testFunction;
1079  m_testFunction2 = theRHS.m_testFunction2;
1080 
1081  return *this;
1082  }
1083 
1084  protected:
1085 
1086  eMatchScore
1087  initialize(
1088  XPathConstructionContext& theConstructionContext,
1089  const XalanDOMString& theNameTest,
1090  const PrefixResolver& thePrefixResolver,
1091  const Locator* theLocator);
1092 
1093  eMatchScore
1094  initialize(
1095  const XalanDOMString& theNamespaceURI,
1096  const XalanDOMString& theLocalName);
1097 
1098  private:
1099 
1100 
1101  typedef eMatchScore (NodeTester::*TestFunctionPtr)(const XalanNode&, XalanNode::NodeType) const;
1102  typedef eMatchScore (NodeTester::*TestFunctionPtr2)(const XalanElement&) const;
1103 
1104 
1105  eMatchScore
1106  testComment(
1107  const XalanNode& context,
1108  XalanNode::NodeType nodeType) const;
1109 
1110  eMatchScore
1111  testText(
1112  const XalanNode& context,
1113  XalanNode::NodeType nodeType) const;
1114 
1115  eMatchScore
1116  testPI(
1117  const XalanNode& context,
1118  XalanNode::NodeType nodeType) const;
1119 
1120  eMatchScore
1121  testPIName(
1122  const XalanNode& context,
1123  XalanNode::NodeType nodeType) const;
1124 
1125  eMatchScore
1126  testNode(
1127  const XalanNode& context,
1128  XalanNode::NodeType nodeType) const;
1129 
1130  eMatchScore
1131  testRoot(
1132  const XalanNode& context,
1133  XalanNode::NodeType nodeType) const;
1134 
1135  eMatchScore
1136  testAttributeNCName(
1137  const XalanNode& context,
1138  XalanNode::NodeType nodeType) const;
1139 
1140  eMatchScore
1141  testAttributeQName(
1142  const XalanNode& context,
1143  XalanNode::NodeType nodeType) const;
1144 
1145  eMatchScore
1146  testAttributeNamespaceOnly(
1147  const XalanNode& context,
1148  XalanNode::NodeType nodeType) const;
1149 
1150  eMatchScore
1151  testAttributeTotallyWild(
1152  const XalanNode& context,
1153  XalanNode::NodeType nodeType) const;
1154 
1155  eMatchScore
1156  testElementNCName(
1157  const XalanNode& context,
1158  XalanNode::NodeType nodeType) const;
1159 
1160  eMatchScore
1161  testElementQName(
1162  const XalanNode& context,
1163  XalanNode::NodeType nodeType) const;
1164 
1165  eMatchScore
1166  testElementNamespaceOnly(
1167  const XalanNode& context,
1168  XalanNode::NodeType nodeType) const;
1169 
1170  eMatchScore
1171  testElementTotallyWild(
1172  const XalanNode& context,
1173  XalanNode::NodeType nodeType) const;
1174 
1175  eMatchScore
1176  testElementNCName2(const XalanElement& context) const;
1177 
1178  eMatchScore
1179  testElementQName2(const XalanElement& context) const;
1180 
1181  eMatchScore
1182  testElementNamespaceOnly2(const XalanElement& context) const;
1183 
1184  eMatchScore
1185  testElementTotallyWild2(const XalanElement& context) const;
1186 
1187  eMatchScore
1188  testNamespaceNCName(
1189  const XalanNode& context,
1190  XalanNode::NodeType nodeType) const;
1191 
1192  eMatchScore
1193  testNamespaceTotallyWild(
1194  const XalanNode& context,
1195  XalanNode::NodeType nodeType) const;
1196 
1197  eMatchScore
1198  testDefault(
1199  const XalanNode& context,
1200  XalanNode::NodeType nodeType) const;
1201 
1202  eMatchScore
1203  testDefault2(const XalanElement& context) const;
1204 
1205  bool
1206  matchLocalName(const XalanNode& context) const;
1207 
1208  bool
1209  matchNamespaceURI(const XalanNode& context) const;
1210 
1211  bool
1212  matchLocalNameAndNamespaceURI(const XalanNode& context) const;
1213 
1214  bool
1215  matchNamespace(const XalanNode& context) const;
1216 
1217  bool
1218  shouldStripSourceNode(const XalanText& context) const;
1219 
1220  // Data members...
1221  XPathExecutionContext* m_executionContext;
1222 
1223  const XalanDOMString* m_targetNamespace;
1224 
1225  const XalanDOMString* m_targetLocalName;
1226 
1227  TestFunctionPtr m_testFunction;
1228 
1229  TestFunctionPtr2 m_testFunction2;
1230  };
1231 
1232  friend class NodeTester;
1233 
1234 protected:
1235 
1236  /**
1237  * Execute a location path.
1238  *
1239  * @param context current source tree context node
1240  * @param opPos current position in the Op Mpa
1241  * @param executionContext current execution context
1242  * @return node-set
1243  */
1244  const XObjectPtr
1245  locationPath(
1246  XalanNode* context,
1247  OpCodeMapPositionType opPos,
1248  XPathExecutionContext& executionContext) const;
1249 
1250  /**
1251  * Execute a location path.
1252  *
1253  * @param context current source tree context node
1254  * @param opPos current position in the Op Map
1255  * @param executionContext current execution context
1256  * @param theResult the result as a node list
1257  */
1258  void
1259  locationPath(
1260  XalanNode* context,
1261  OpCodeMapPositionType opPos,
1262  XPathExecutionContext& executionContext,
1263  bool& theResult) const;
1264 
1265  /**
1266  * Execute a location path.
1267  *
1268  * @param context current source tree context node
1269  * @param opPos current position in the Op Map
1270  * @param executionContext current execution context
1271  * @param theResult the result as a node list
1272  */
1273  void
1274  locationPath(
1275  XalanNode* context,
1276  OpCodeMapPositionType opPos,
1277  XPathExecutionContext& executionContext,
1278  double& theResult) const;
1279 
1280  /**
1281  * Execute a location path.
1282  *
1283  * @param context current source tree context node
1284  * @param opPos current position in the Op Map
1285  * @param executionContext current execution context
1286  * @param theResult the result as a node list
1287  */
1288  void
1289  locationPath(
1290  XalanNode* context,
1291  OpCodeMapPositionType opPos,
1292  XPathExecutionContext& executionContext,
1293  XalanDOMString& theResult) const;
1294 
1295  /**
1296  * Execute a location path.
1297  *
1298  * @param context current source tree context node
1299  * @param opPos current position in the Op Map
1300  * @param executionContext current execution context
1301  * @param formatterListener the FormatterListener instance to receive the result
1302  * @param function A pointer to the member function of FormatterListener to call
1303  */
1304  void
1305  locationPath(
1306  XalanNode* context,
1307  OpCodeMapPositionType opPos,
1308  XPathExecutionContext& executionContext,
1309  FormatterListener& formatterListener,
1310  MemberFunctionPtr function) const;
1311 
1312  /**
1313  * Execute a location path.
1314  *
1315  * @param context current source tree context node
1316  * @param opPos current position in the Op Map
1317  * @param executionContext current execution context
1318  * @param theResult the result as a node list
1319  */
1320  void
1322  XalanNode* context,
1323  OpCodeMapPositionType opPos,
1324  XPathExecutionContext& executionContext,
1325  MutableNodeRefList& theResult) const
1326  {
1327  step(executionContext, context, opPos + 2, theResult);
1328  }
1329 
1330  /**
1331  * Execute the XPath from the provided context.
1332  *
1333  * @param context current source tree context node
1334  * @param opPos current position in the Op Map
1335  * @param executionContext current execution context
1336  * @return pointer to union of node-set operands
1337  */
1338  const XObjectPtr
1339  executeMore(
1340  XalanNode* context,
1341  OpCodeMapPositionType opPos,
1342  XPathExecutionContext& executionContext) const;
1343 
1344  /**
1345  * Execute the XPath from the provided context.
1346  *
1347  * @param context current source tree context node
1348  * @param opPos current position in the Op Map
1349  * @param executionContext current execution context
1350  * @param theResult The result of the execution
1351  */
1352  void
1353  executeMore(
1354  XalanNode* context,
1355  OpCodeMapPositionType opPos,
1356  XPathExecutionContext& executionContext,
1357  bool& theResult) const;
1358 
1359  /**
1360  * Execute the XPath from the provided context.
1361  *
1362  * @param context current source tree context node
1363  * @param opPos current position in the Op Map
1364  * @param executionContext current execution context
1365  * @param theResult The result of the execution
1366  */
1367  void
1368  executeMore(
1369  XalanNode* context,
1370  OpCodeMapPositionType opPos,
1371  XPathExecutionContext& executionContext,
1372  double& theResult) const;
1373 
1374  /**
1375  * Execute the XPath from the provided context. The result
1376  * is appended to the supplied string.
1377  *
1378  * @param context current source tree context node
1379  * @param opPos current position in the Op Map
1380  * @param executionContext current execution context
1381  * @param theResult The result of the execution
1382  */
1383  void
1384  executeMore(
1385  XalanNode* context,
1386  OpCodeMapPositionType opPos,
1387  XPathExecutionContext& executionContext,
1388  XalanDOMString& theResult) const;
1389 
1390  /**
1391  * Execute the XPath from the provided context.
1392  *
1393  * @param context current source tree context node
1394  * @param opPos current position in the Op Map
1395  * @param executionContext current execution context
1396  * @param formatterListener the FormatterListener instance to receive the result
1397  * @param function A pointer to the member function of FormatterListener to call
1398  */
1399  void
1400  executeMore(
1401  XalanNode* context,
1402  OpCodeMapPositionType opPos,
1403  XPathExecutionContext& executionContext,
1404  FormatterListener& formatterListener,
1405  MemberFunctionPtr function) const;
1406 
1407  /**
1408  * Execute the XPath from the provided context.
1409  *
1410  * @param context current source tree context node
1411  * @param opPos current position in the Op Map
1412  * @param executionContext current execution context
1413  * @param theResult The result of the execution
1414  * @return the node-set result, if the result was not returned in the parameter
1415  */
1416  const XObjectPtr
1417  executeMore(
1418  XalanNode* context,
1419  OpCodeMapPositionType opPos,
1420  XPathExecutionContext& executionContext,
1421  MutableNodeRefList& theResult) const;
1422 
1423  /**
1424  * Helper function to get match score.
1425  * @param context The current source tree context node.
1426  * @param executionContext The current execution context
1427  * @param score The match score
1428  */
1429  void
1430  doGetMatchScore(
1431  XalanNode* context,
1432  XPathExecutionContext& executionContext,
1433  eMatchScore& score) const;
1434 
1435  /**
1436  * OR two expressions and return the boolean result.
1437  * @param context The current source tree context node.
1438  * @param opPos The current position in the Op Map.
1439  * @param executionContext current execution context
1440  * @return true if the one of the two arguments are true.
1441  */
1442  bool
1443  Or(
1444  XalanNode* context,
1445  OpCodeMapPositionType opPos,
1446  XPathExecutionContext& executionContext) const;
1447 
1448  /**
1449  * OR two expressions and return the boolean result.
1450  * @param context The current source tree context node.
1451  * @param opPos The current position in the Op Map.
1452  * @param executionContext current execution context
1453  * @return true if the two arguments are both true.
1454  */
1455  bool
1456  And(
1457  XalanNode* context,
1458  OpCodeMapPositionType opPos,
1459  XPathExecutionContext& executionContext) const;
1460 
1461  /**
1462  * Tell if two expressions are functionally not equal.
1463  * @param context The current source tree context node.
1464  * @param opPos The current position in the Op Map.
1465  * @param executionContext current execution context
1466  * @return true if the two arguments are not equal.
1467  */
1468  bool
1469  notequals(
1470  XalanNode* context,
1471  OpCodeMapPositionType opPos,
1472  XPathExecutionContext& executionContext) const;
1473 
1474  /**
1475  * Tell if two expressions are functionally equal.
1476  * @param context The current source tree context node.
1477  * @param opPos The current position in the Op Map.
1478  * @param executionContext current execution context
1479  * @return true if the two arguments are equal.
1480  */
1481  bool
1482  equals(
1483  XalanNode* context,
1484  OpCodeMapPositionType opPos,
1485  XPathExecutionContext& executionContext) const;
1486 
1487  /**
1488  * Tell if one argument is less than or equal to the other argument.
1489  * @param context The current source tree context node.
1490  * @param opPos The current position in the Op Map.
1491  * @param executionContext current execution context
1492  * @return true if arg 1 is less than or equal to arg 2.
1493  */
1494  bool
1495  lte(
1496  XalanNode* context,
1497  OpCodeMapPositionType opPos,
1498  XPathExecutionContext& executionContext) const;
1499 
1500  /**
1501  * Tell if one argument is less than the other argument.
1502  * @param context The current source tree context node.
1503  * @param opPos The current position in the Op Map.
1504  * @param executionContext current execution context
1505  * @return true if arg 1 is less than arg 2.
1506  */
1507  bool
1508  lt(
1509  XalanNode* context,
1510  OpCodeMapPositionType opPos,
1511  XPathExecutionContext& executionContext) const;
1512 
1513  /**
1514  * Tell if one argument is greater than or equal to the other argument.
1515  * @param context The current source tree context node.
1516  * @param opPos The current position in the Op Map.
1517  * @param executionContext current execution context
1518  * @return true if arg 1 is greater than or equal to arg 2.
1519  */
1520  bool
1521  gte(
1522  XalanNode* context,
1523  OpCodeMapPositionType opPos,
1524  XPathExecutionContext& executionContext) const;
1525 
1526  /**
1527  * Tell if one argument is greater than the other argument.
1528  * @param context The current source tree context node.
1529  * @param opPos The current position in the Op Map.
1530  * @param executionContext current execution context
1531  * @return true if arg 1 is greater than arg 2.
1532  */
1533  bool
1534  gt(
1535  XalanNode* context,
1536  OpCodeMapPositionType opPos,
1537  XPathExecutionContext& executionContext) const;
1538 
1539  /**
1540  * Give the sum of two arguments.
1541  * @param context The current source tree context node.
1542  * @param opPos The current position in the Op Map.
1543  * @param executionContext current execution context
1544  * @return sum of arg1 and arg2.
1545  */
1546  double
1547  plus(
1548  XalanNode* context,
1549  OpCodeMapPositionType opPos,
1550  XPathExecutionContext& executionContext) const;
1551 
1552  /**
1553  * Give the sum of two arguments.
1554  * @param context The current source tree context node.
1555  * @param opPos The current position in the Op Map.
1556  * @param executionContext current execution context
1557  * @param formatterListener the FormatterListener instance to receive the result
1558  * @param function A pointer to the member function of FormatterListener to call
1559  */
1560  void
1561  plus(
1562  XalanNode* context,
1563  OpCodeMapPositionType opPos,
1564  XPathExecutionContext& executionContext,
1565  FormatterListener& formatterListener,
1566  MemberFunctionPtr function) const;
1567 
1568  /**
1569  * Give the difference of two arguments.
1570  * @param context The current source tree context node.
1571  * @param opPos The current position in the Op Map.
1572  * @param executionContext current execution context
1573  * @return difference of arg1 and arg2.
1574  */
1575  double
1576  minus(
1577  XalanNode* context,
1578  OpCodeMapPositionType opPos,
1579  XPathExecutionContext& executionContext) const;
1580 
1581  /**
1582  * Give the difference of two arguments.
1583  * @param context The current source tree context node.
1584  * @param opPos The current position in the Op Map.
1585  * @param executionContext current execution context
1586  * @param formatterListener the FormatterListener instance to receive the result
1587  * @param function A pointer to the member function of FormatterListener to call
1588  */
1589  void
1590  minus(
1591  XalanNode* context,
1592  OpCodeMapPositionType opPos,
1593  XPathExecutionContext& executionContext,
1594  FormatterListener& formatterListener,
1595  MemberFunctionPtr function) const;
1596 
1597  /**
1598  * Multiply two arguments.
1599  * @param context The current source tree context node.
1600  * @param opPos The current position in the Op Map.
1601  * @param executionContext current execution context
1602  * @return arg1 * arg2.
1603  */
1604  double
1605  mult(
1606  XalanNode* context,
1607  OpCodeMapPositionType opPos,
1608  XPathExecutionContext& executionContext) const;
1609 
1610  /**
1611  * Multiply two arguments.
1612  * @param context The current source tree context node.
1613  * @param opPos The current position in the Op Map.
1614  * @param executionContext current execution context
1615  * @param formatterListener the FormatterListener instance to receive the result
1616  * @param function A pointer to the member function of FormatterListener to call
1617  */
1618  void
1619  mult(
1620  XalanNode* context,
1621  OpCodeMapPositionType opPos,
1622  XPathExecutionContext& executionContext,
1623  FormatterListener& formatterListener,
1624  MemberFunctionPtr function) const;
1625 
1626  /**
1627  * Divide a number.
1628  * @param context The current source tree context node.
1629  * @param opPos The current position in the Op Map.
1630  * @param executionContext current execution context
1631  * @return arg1 / arg2.
1632  */
1633  double
1634  div(
1635  XalanNode* context,
1636  OpCodeMapPositionType opPos,
1637  XPathExecutionContext& executionContext) const;
1638 
1639  /**
1640  * Divide a number.
1641  * @param context The current source tree context node.
1642  * @param opPos The current position in the Op Map.
1643  * @param executionContext current execution context
1644  * @param formatterListener the FormatterListener instance to receive the result
1645  * @param function A pointer to the member function of FormatterListener to call
1646  */
1647  void
1648  div(
1649  XalanNode* context,
1650  OpCodeMapPositionType opPos,
1651  XPathExecutionContext& executionContext,
1652  FormatterListener& formatterListener,
1653  MemberFunctionPtr function) const;
1654 
1655  /**
1656  * Return the remainder from a truncating division.
1657  * @param context The current source tree context node.
1658  * @param opPos The current position in the Op Map.
1659  * @param executionContext current execution context
1660  * @return arg1 mod arg2.
1661  */
1662  double
1663  mod(
1664  XalanNode* context,
1665  OpCodeMapPositionType opPos,
1666  XPathExecutionContext& executionContext) const;
1667 
1668  /**
1669  * Return the remainder from a truncating division.
1670  * @param context The current source tree context node.
1671  * @param opPos The current position in the Op Map.
1672  * @param executionContext current execution context
1673  * @param formatterListener the FormatterListener instance to receive the result
1674  * @param function A pointer to the member function of FormatterListener to call
1675  */
1676  void
1677  mod(
1678  XalanNode* context,
1679  OpCodeMapPositionType opPos,
1680  XPathExecutionContext& executionContext,
1681  FormatterListener& formatterListener,
1682  MemberFunctionPtr function) const;
1683 
1684  /**
1685  * Return the negation of a number.
1686  * @param context The current source tree context node.
1687  * @param opPos The current position in the Op Map.
1688  * @param executionContext current execution context
1689  * @return -arg.
1690  */
1691  double
1692  neg(
1693  XalanNode* context,
1694  OpCodeMapPositionType opPos,
1695  XPathExecutionContext& executionContext) const;
1696 
1697  /**
1698  * Return the negation of a number.
1699  * @param context The current source tree context node.
1700  * @param opPos The current position in the Op Map.
1701  * @param executionContext current execution context
1702  * @param formatterListener the FormatterListener instance to receive the result
1703  * @param function A pointer to the member function of FormatterListener to call
1704  */
1705  void
1706  neg(
1707  XalanNode* context,
1708  OpCodeMapPositionType opPos,
1709  XPathExecutionContext& executionContext,
1710  FormatterListener& formatterListener,
1711  MemberFunctionPtr function) const;
1712 
1713  /**
1714  * Computes the union of its operands which must be node-sets.
1715  * @param context The current source tree context node.
1716  * @param opPos The current position in the Op Map.
1717  * @param executionContext current execution context
1718  * @return the union of node-set operands.
1719  */
1720  const XObjectPtr
1721  Union(
1722  XalanNode* context,
1723  OpCodeMapPositionType opPos,
1724  XPathExecutionContext& executionContext) const;
1725 
1726  /**
1727  * Computes the union of its operands which must be node-sets.
1728  *
1729  * @param context The current source tree context node.
1730  * @param opPos The current position in the Op Map.
1731  * @param executionContext current execution context
1732  * @result the result of the union of node-set operands.
1733  */
1734  void
1735  Union(
1736  XalanNode* context,
1737  OpCodeMapPositionType opPos,
1738  XPathExecutionContext& executionContext,
1739  bool& result) const;
1740 
1741  /**
1742  * Computes the union of its operands which must be node-sets.
1743  *
1744  * @param context The current source tree context node.
1745  * @param opPos The current position in the Op Map.
1746  * @param executionContext current execution context
1747  * @result the result of the union of node-set operands.
1748  */
1749  void
1750  Union(
1751  XalanNode* context,
1752  OpCodeMapPositionType opPos,
1753  XPathExecutionContext& executionContext,
1754  double& result) const;
1755 
1756  /**
1757  * Computes the union of its operands which must be node-sets.
1758  *
1759  * @param context The current source tree context node.
1760  * @param opPos The current position in the Op Map.
1761  * @param executionContext current execution context
1762  * @result the result of the union of node-set operands.
1763  */
1764  void
1765  Union(
1766  XalanNode* context,
1767  OpCodeMapPositionType opPos,
1768  XPathExecutionContext& executionContext,
1769  XalanDOMString& result) const;
1770 
1771  /**
1772  * Computes the union of its operands which must be node-sets.
1773  *
1774  * @param context The current source tree context node.
1775  * @param opPos The current position in the Op Map.
1776  * @param executionContext current execution context
1777  * @param formatterListener the FormatterListener instance to receive the result
1778  * @param function A pointer to the member function of FormatterListener to call
1779  */
1780  void
1781  Union(
1782  XalanNode* context,
1783  OpCodeMapPositionType opPos,
1784  XPathExecutionContext& executionContext,
1785  FormatterListener& formatterListener,
1786  MemberFunctionPtr function) const;
1787 
1788  /**
1789  * Computes the union of its operands which must be node-sets.
1790  * @param context The current source tree context node.
1791  * @param opPos The current position in the Op Map.
1792  * @param executionContext current execution context
1793  * @result the result of the union of node-set operands.
1794  */
1795  void
1796  Union(
1797  XalanNode* context,
1798  OpCodeMapPositionType opPos,
1799  XPathExecutionContext& executionContext,
1800  MutableNodeRefList& result) const;
1801 
1802  /**
1803  * Get a literal value.
1804  * @param opPos The current position in the Op Map.
1805  * @param executionContext current execution context
1806  * @return an XObject object.
1807  */
1808  const XObjectPtr
1809  literal(
1810  OpCodeMapPositionType opPos,
1811  XPathExecutionContext& executionContext) const;
1812 
1813  /**
1814  * Get a literal value as a boolean.
1815  *
1816  * @param opPos The current position in the Op Map.
1817  * @param theResult The value.
1818  */
1819  void
1820  literal(
1821  OpCodeMapPositionType opPos,
1822  bool& theResult) const;
1823 
1824  /**
1825  * Get a literal value as a number.
1826  *
1827  * @param opPos The current position in the Op Map.
1828  * @param theResult The value.
1829  */
1830  void
1831  literal(
1832  OpCodeMapPositionType opPos,
1833  double& theResult) const;
1834 
1835  /**
1836  * Get a literal value. The value is appended to the
1837  * supplied string.
1838  *
1839  * @param opPos The current position in the Op Map.
1840  * @param theResult The string.
1841  */
1842  void
1843  literal(
1844  OpCodeMapPositionType opPos,
1845  XalanDOMString& theResult) const;
1846 
1847  /**
1848  * Get a literal value.
1849  * @param opPos The current position in the Op Map.
1850  * @param executionContext current execution context
1851  * @return The result as a double.
1852  */
1853  void
1854  literal(
1855  OpCodeMapPositionType opPos,
1856  FormatterListener& formatterListener,
1857  MemberFunctionPtr function) const;
1858 
1859  /**
1860  * Get the value of a variable.
1861  * @param opPos The current position in the Op Map.
1862  * @param executionContext current execution context
1863  * @return an XObject object.
1864  */
1865  const XObjectPtr
1866  variable(
1867  OpCodeMapPositionType opPos,
1868  XPathExecutionContext& executionContext) const;
1869 
1870  /**
1871  * Execute an expression as a group.
1872  * @param context The current source tree context node.
1873  * @param opPos The current position in the Op Map.
1874  * @param executionContext current execution context
1875  * @return arg.
1876  */
1877  const XObjectPtr
1879  XalanNode* context,
1880  OpCodeMapPositionType opPos,
1881  XPathExecutionContext& executionContext) const
1882  {
1883  return executeMore(context, opPos + 2, executionContext);
1884  }
1885 
1886  /**
1887  * Execute an expression as a group.
1888  * @param context The current source tree context node.
1889  * @param opPos The current position in the Op Map.
1890  * @param executionContext current execution context
1891  * @param theResult The result of the execution
1892  */
1893  void
1895  XalanNode* context,
1896  OpCodeMapPositionType opPos,
1897  XPathExecutionContext& executionContext,
1898  bool& theResult) const
1899  {
1900  executeMore(context, opPos + 2, executionContext, theResult);
1901  }
1902 
1903  /**
1904  * Execute an expression as a group.
1905  * @param context The current source tree context node.
1906  * @param opPos The current position in the Op Map.
1907  * @param executionContext current execution context
1908  * @param theResult The result of the execution
1909  */
1910  void
1912  XalanNode* context,
1913  OpCodeMapPositionType opPos,
1914  XPathExecutionContext& executionContext,
1915  double& theResult) const
1916  {
1917  executeMore(context, opPos + 2, executionContext, theResult);
1918  }
1919 
1920  /**
1921  * Execute an expression as a group.
1922  * @param context The current source tree context node.
1923  * @param opPos The current position in the Op Map.
1924  * @param executionContext current execution context
1925  * @param theResult The result of the execution
1926  */
1927  void
1929  XalanNode* context,
1930  OpCodeMapPositionType opPos,
1931  XPathExecutionContext& executionContext,
1932  XalanDOMString& theResult) const
1933  {
1934  executeMore(context, opPos + 2, executionContext, theResult);
1935  }
1936 
1937  /**
1938  * Execute an expression as a group.
1939  *
1940  * @param context The current source tree context node.
1941  * @param opPos The current position in the Op Map.
1942  * @param executionContext current execution context
1943  * @param formatterListener the FormatterListener instance to receive the result
1944  * @param function A pointer to the member function of FormatterListener to call
1945  */
1946  void
1948  XalanNode* context,
1949  OpCodeMapPositionType opPos,
1950  XPathExecutionContext& executionContext,
1951  FormatterListener& formatterListener,
1952  MemberFunctionPtr function) const
1953  {
1954  executeMore(
1955  context,
1956  opPos + 2,
1957  executionContext,
1958  formatterListener,
1959  function);
1960  }
1961 
1962  /**
1963  * Execute an expression as a group.
1964  * @param context The current source tree context node.
1965  * @param opPos The current position in the Op Map.
1966  * @param executionContext current execution context
1967  * @param theResult The result of the execution
1968  */
1969  void
1971  XalanNode* context,
1972  OpCodeMapPositionType opPos,
1973  XPathExecutionContext& executionContext,
1974  MutableNodeRefList& theResult) const
1975  {
1976  const XObjectPtr theValue(executeMore(
1977  context,
1978  opPos + 2,
1979  executionContext,
1980  theResult));
1981 
1982  if (theValue.null() == false)
1983  {
1984  theResult.addNodesInDocOrder(
1985  theValue->nodeset(),
1986  executionContext);
1987 
1988  theResult.setDocumentOrder();
1989  }
1990  }
1991 
1992  /**
1993  * Get a literal value.
1994  * @param opPos The current position in the Op Map.
1995  * @return The result as a double.
1996  */
1997  double
1998  numberlit(OpCodeMapPositionType opPos) const;
1999 
2000  /**
2001  * Get a literal value.
2002  * @param opPos The current position in the Op Map.
2003  * @return The result as a double.
2004  */
2005  const XObjectPtr
2006  numberlit(
2007  OpCodeMapPositionType opPos,
2008  XPathExecutionContext& executionContext) const;
2009 
2010  /**
2011  * Get a literal value as a boolean.
2012  *
2013  * @param opPos The current position in the Op Map.
2014  * @param theResult The string.
2015  */
2016  void
2017  numberlit(
2018  OpCodeMapPositionType opPos,
2019  bool& theResult) const;
2020 
2021  /**
2022  * Get a literal value. The value is appended to the
2023  * supplied string.
2024  *
2025  * @param opPos The current position in the Op Map.
2026  * @param theResult The string.
2027  */
2028  void
2029  numberlit(
2030  OpCodeMapPositionType opPos,
2031  XalanDOMString& theResult) const;
2032 
2033  /**
2034  * Get a literal value.
2035  *
2036  * @param opPos The current position in the Op Map.
2037  * @param formatterListener the FormatterListener instance to receive the result
2038  * @param function A pointer to the member function of FormatterListener to call
2039  */
2040  void
2041  numberlit(
2042  OpCodeMapPositionType opPos,
2043  FormatterListener& formatterListener,
2044  MemberFunctionPtr function) const;
2045 
2046  /**
2047  * Setup for and run an extension function.
2048  * @param context The current source tree context node.
2049  * @param opPos The current position in the Op Map.
2050  * @param executionContext current execution context
2051  * @return the result of the function.
2052  */
2053  const XObjectPtr
2054  runExtFunction(
2055  XalanNode* context,
2056  OpCodeMapPositionType opPos,
2057  XPathExecutionContext& executionContext) const;
2058 
2059  /**
2060  * Handle an extension function.
2061  * @param context The current source tree context node.
2062  * @param opPos The current position in the Op Map.
2063  * @param theNamespace The namespace of the function.
2064  * @param functionName The name of the function.
2065  * @param executionContext current execution context
2066  * @return the result of the function.
2067  */
2068  const XObjectPtr
2070  XalanNode* context,
2071  OpCodeMapPositionType /* opPos */,
2072  const XalanDOMString& theNamespace,
2073  const XalanDOMString& functionName,
2074  const Function::XObjectArgVectorType& argVec,
2075  XPathExecutionContext& executionContext) const
2076  {
2077  return executionContext.extFunction(theNamespace,
2078  functionName,
2079  context,
2080  argVec,
2081  m_locator);
2082  }
2083 
2084  /**
2085  * Setup for and run a function.
2086  * @param context The current source tree context node.
2087  * @param opPos The current position in the Op Map.
2088  * @param executionContext current execution context
2089  * @return the result of the function.
2090  */
2091  const XObjectPtr
2092  runFunction(
2093  XalanNode* context,
2094  OpCodeMapPositionType opPos,
2095  XPathExecutionContext& executionContext) const;
2096 
2097  /**
2098  * Handle a built-in function.
2099  * @param context The current source tree context node.
2100  * @param funcID The function ID.
2101  * @param argVec The arguments for the function.
2102  * @param executionContext current execution context
2103  * @return the result of the function.
2104  */
2105  const XObjectPtr
2106  function(
2107  XalanNode* context,
2108  OpCodeMapValueType funcID,
2109  const Function::XObjectArgVectorType& argVec,
2110  XPathExecutionContext& executionContext) const
2111  {
2112  return s_functions[funcID].execute(executionContext, context, argVec, m_locator);
2113  }
2114 
2115  /**
2116  * Handle the built-in function "position".
2117  *
2118  * @param context The current source tree context node, which must not be 0.
2119  * @param executionContext current execution context
2120  * @return the result of the function.
2121  */
2122  double
2124  XalanNode* context,
2125  XPathExecutionContext& executionContext) const
2126  {
2127  assert(context != 0);
2128 
2129  const XPathExecutionContext::size_type theResult =
2130  executionContext.getContextNodeListPosition(*context);
2131  assert(static_cast<double>(theResult) == theResult);
2132 
2133  return static_cast<double>(theResult);
2134  }
2135 
2136  /**
2137  * Handle the built-in function "last".
2138  *
2139  * @param executionContext current execution context
2140  * @return the result of the function.
2141  */
2142  double
2143  functionLast(XPathExecutionContext& executionContext) const
2144  {
2145  const XPathExecutionContext::size_type theResult =
2146  executionContext.getContextNodeListLength();
2147  assert(static_cast<double>(theResult) == theResult);
2148 
2149  return static_cast<double>(theResult);
2150  }
2151 
2152  /**
2153  * Handle the built-in function "count".
2154  *
2155  * @param context The current source tree context node.
2156  * @param opPos The current position in the Op Map.
2157  * @param executionContext current execution context
2158  * @return the result of the function.
2159  */
2160  double
2161  functionCount(
2162  XalanNode* context,
2163  OpCodeMapPositionType opPos,
2164  XPathExecutionContext& executionContext) const;
2165 
2166  /**
2167  * Handle the built-in function "not".
2168  *
2169  * @param context The current source tree context node, which must not be 0.
2170  * @param opPos The current position in the Op Map.
2171  * @param executionContext current execution context
2172  * @return the result of the function.
2173  */
2174  bool
2176  XalanNode* context,
2177  OpCodeMapPositionType opPos,
2178  XPathExecutionContext& executionContext) const
2179  {
2180  assert(context != 0);
2181 
2182  return !functionBoolean(context, opPos, executionContext);
2183  }
2184 
2185  /**
2186  * Handle the built-in function "boolean".
2187  *
2188  * @param context The current source tree context node, which must not be 0.
2189  * @param opPos The current position in the Op Map.
2190  * @param executionContext current execution context
2191  * @return the result of the function.
2192  */
2193  bool
2195  XalanNode* context,
2196  OpCodeMapPositionType opPos,
2197  XPathExecutionContext& executionContext) const
2198  {
2199  assert(context != 0);
2200 
2201  bool result;
2202 
2203  executeMore(context, opPos + 2, executionContext, result);
2204 
2205  return result;
2206  }
2207 
2208  /**
2209  * Handle the built-in function "name".
2210  *
2211  * @param context The current source tree context node, which must not be 0.
2212  * @return the result of the function.
2213  */
2214  const XalanDOMString&
2215  functionName(XalanNode* context) const
2216  {
2217  assert(context != 0);
2218 
2219  return DOMServices::getNameOfNode(*context);
2220  }
2221 
2222  /**
2223  * Handle the built-in function "name".
2224  *
2225  * @param context The current source tree context node, which must not be 0.
2226  * @param opPos The current position in the Op Map.
2227  * @param executionContext current execution context
2228  * @return the result of the function.
2229  */
2230  const XalanDOMString&
2231  functionName(
2232  XalanNode* context,
2233  OpCodeMapPositionType opPos,
2234  XPathExecutionContext& executionContext) const;
2235 
2236  /**
2237  * Handle the built-in function "local-name".
2238  *
2239  * @param context The current source tree context node, which must not be 0.
2240  * @return the result of the function.
2241  */
2242  const XalanDOMString&
2243  functionLocalName(XalanNode* context) const;
2244 
2245  /**
2246  * Handle the built-in function "local-name".
2247  *
2248  * @param context The current source tree context node, which must not be 0.
2249  * @param opPos The current position in the Op Map.
2250  * @param executionContext current execution context
2251  * @return the result of the function.
2252  */
2253  const XalanDOMString&
2254  functionLocalName(
2255  XalanNode* context,
2256  OpCodeMapPositionType opPos,
2257  XPathExecutionContext& executionContext) const;
2258 
2259  /**
2260  * Handle the built-in function "number".
2261  *
2262  * @param context The current source tree context node, which must not be 0.
2263  * @param executionContext current execution context
2264  * @return the result of the function.
2265  */
2266  double
2268  XalanNode* context,
2269  XPathExecutionContext& executionContext) const
2270  {
2271  assert(context != 0);
2272 
2273  return XObject::number(executionContext, *context);
2274  }
2275 
2276  /**
2277  * Handle the built-in function "number".
2278  *
2279  * @param context The current source tree context node, which must not be 0.
2280  * @param opPos The current position in the Op Map.
2281  * @param executionContext current execution context
2282  * @return the result of the function.
2283  */
2284  double
2286  XalanNode* context,
2287  OpCodeMapPositionType opPos,
2288  XPathExecutionContext& executionContext) const
2289  {
2290  double result;
2291 
2292  executeMore(context, opPos + 2, executionContext, result);
2293 
2294  return result;
2295  }
2296 
2297  /**
2298  * Handle the built-in function "floor".
2299  *
2300  * @param context The current source tree context node, which must not be 0.
2301  * @param opPos The current position in the Op Map.
2302  * @param executionContext current execution context
2303  * @return the result of the function.
2304  */
2305  double
2307  XalanNode* context,
2308  OpCodeMapPositionType opPos,
2309  XPathExecutionContext& executionContext) const
2310  {
2311  return DoubleSupport::floor(functionNumber(context, opPos, executionContext));
2312  }
2313 
2314  /**
2315  * Handle the built-in function "ceiling".
2316  *
2317  * @param context The current source tree context node, which must not be 0.
2318  * @param opPos The current position in the Op Map.
2319  * @param executionContext current execution context
2320  * @return the result of the function.
2321  */
2322  double
2324  XalanNode* context,
2325  OpCodeMapPositionType opPos,
2326  XPathExecutionContext& executionContext) const
2327  {
2328  return DoubleSupport::ceiling(functionNumber(context, opPos, executionContext));
2329  }
2330 
2331  /**
2332  * Handle the built-in function "round".
2333  *
2334  * @param context The current source tree context node, which must not be 0.
2335  * @param opPos The current position in the Op Map.
2336  * @param executionContext current execution context
2337  * @return the result of the function.
2338  */
2339  double
2341  XalanNode* context,
2342  OpCodeMapPositionType opPos,
2343  XPathExecutionContext& executionContext) const
2344  {
2345  return DoubleSupport::round(functionNumber(context, opPos, executionContext));
2346  }
2347 
2348  /**
2349  * Handle the built-in function "string-length".
2350  *
2351  * @param context The current source tree context node, which must not be 0.
2352  * @param executionContext current execution context
2353  * @return the result of the function.
2354  */
2355  double
2356  functionStringLength(
2357  XalanNode* context,
2358  XPathExecutionContext& executionContext) const;
2359 
2360  /**
2361  * Handle the built-in function "string-length".
2362  *
2363  * @param context The current source tree context node, which must not be 0.
2364  * @param opPos The current position in the Op Map.
2365  * @param executionContext current execution context
2366  * @return the result of the function.
2367  */
2368  double
2369  functionStringLength(
2370  XalanNode* context,
2371  OpCodeMapPositionType opPos,
2372  XPathExecutionContext& executionContext) const;
2373 
2374  /**
2375  * Handle the built-in function "sum".
2376  *
2377  * @param context The current source tree context node.
2378  * @param opPos The current position in the Op Map.
2379  * @param executionContext current execution context
2380  * @return the result of the function.
2381  */
2382  double
2383  functionSum(
2384  XalanNode* context,
2385  OpCodeMapPositionType opPos,
2386  XPathExecutionContext& executionContext) const;
2387 
2388  /**
2389  * Get a numeric operand for an expression.
2390  * @param context The current source tree context node.
2391  * @param opPos The current position in the Op Map.
2392  * @param executionContext current execution context
2393  * @return The value of the operand.
2394  */
2395  double
2396  getNumericOperand(
2397  XalanNode* context,
2398  OpCodeMapPositionType opPos,
2399  XPathExecutionContext& executionContext) const;
2400 
2401 private:
2402 
2403  // These are not implemented...
2404  XPath(const XPath&);
2405 
2406  XPath&
2407  operator=(const XPath&);
2408 
2409  bool
2410  operator==(const XPath&) const;
2411 
2412  // Default vector allocation sizes.
2413  enum
2414  {
2415  eDefaultTargetDataSize = 5
2416  };
2417 
2418  OpCodeMapPositionType
2419  getInitialOpCodePosition() const
2420  {
2421 #if defined(XALAN_XPATH_EXPRESSION_USE_ITERATORS)
2422  assert(m_expression.getOpCodeMapValue(0) == XPathExpression::eOP_XPATH);
2423 #else
2424  assert(m_expression.getOpCodeMapValue(
2425  m_expression.getInitialOpCodePosition()) == XPathExpression::eOP_XPATH);
2426 #endif
2427  return m_expression.getInitialOpCodePosition() + 2;
2428  }
2429 
2430  eMatchScore
2431  locationPathPattern(
2432  XPathExecutionContext& executionContext,
2433  XalanNode& context,
2434  OpCodeMapPositionType opPos) const;
2435 
2436 protected:
2437 
2438  /**
2439  * Execute a step in a location path.
2440  *
2441  * @param xpath The xpath that is executing
2442  * @param context The current source tree context node
2443  * @param opPos The current position in the xpath operation map array
2444  * @param queryResults The set of nodes that matches the step.
2445  */
2446  void
2447  step(
2448  XPathExecutionContext& executionContext,
2449  XalanNode* context,
2450  OpCodeMapPositionType opPos,
2451  MutableNodeRefList& queryResults) const;
2452 
2453  /**
2454  * Potentially evaluate a predicate in a match pattern step.
2455  *
2456  * @param executionContext The current execution context.
2457  * @param context The current source tree context node.
2458  * @param opPos The current position in the Op Map.
2459  * @param startOpPos The original position for the step in the Op Map.
2460  * @param score The current match score for the context node.
2461  * @return The resulting match score
2462  */
2463  eMatchScore
2464  doStepPredicate(
2465  XPathExecutionContext& executionContext,
2466  XalanNode* context,
2467  OpCodeMapPositionType opPos,
2468  OpCodeMapPositionType startOpPos,
2469  eMatchScore score) const;
2470 
2471  /**
2472  * Execute a step in a match pattern's location path.
2473  *
2474  * @param xpath The xpath that is executing
2475  * @param context The current source tree context node
2476  * @param opPos The current position in the xpath operation map array
2477  * @param scoreHolder a reference to an eMatchScore to receive
2478  * the result.
2479  * @return the last matched context node
2480  */
2481  XalanNode*
2482  stepPattern(
2483  XPathExecutionContext& executionContext,
2484  XalanNode* context,
2485  OpCodeMapPositionType opPos,
2486  eMatchScore& scoreHolder) const;
2487 
2488  OpCodeMapPositionType
2489  findNodeSet(
2490  XPathExecutionContext& executionContext,
2491  XalanNode* context,
2492  OpCodeMapPositionType opPos,
2493  OpCodeMapValueType stepType,
2494  MutableNodeRefList& subQueryResults) const;
2495 
2496  OpCodeMapPositionType
2497  findRoot(
2498  XPathExecutionContext& executionContext,
2499  XalanNode* context,
2500  OpCodeMapPositionType opPos,
2501  OpCodeMapValueType stepType,
2502  MutableNodeRefList& subQueryResults) const;
2503 
2504  OpCodeMapPositionType
2505  findParent(
2506  XPathExecutionContext& executionContext,
2507  XalanNode* context,
2508  OpCodeMapPositionType opPos,
2509  OpCodeMapValueType stepType,
2510  MutableNodeRefList& subQueryResults) const;
2511 
2512  OpCodeMapPositionType
2513  findSelf(
2514  XPathExecutionContext& executionContext,
2515  XalanNode* context,
2516  OpCodeMapPositionType opPos,
2517  OpCodeMapValueType stepType,
2518  MutableNodeRefList& subQueryResults) const;
2519 
2520  OpCodeMapPositionType
2521  findAncestors(
2522  XPathExecutionContext& executionContext,
2523  XalanNode* context,
2524  OpCodeMapPositionType opPos,
2525  OpCodeMapValueType stepType,
2526  MutableNodeRefList& subQueryResults) const;
2527 
2528  OpCodeMapPositionType
2529  findAncestorsOrSelf(
2530  XPathExecutionContext& executionContext,
2531  XalanNode* context,
2532  OpCodeMapPositionType opPos,
2533  OpCodeMapValueType stepType,
2534  MutableNodeRefList& subQueryResults) const;
2535 
2536  OpCodeMapPositionType
2537  findAttributes(
2538  XPathExecutionContext& executionContext,
2539  XalanNode* context,
2540  OpCodeMapPositionType opPos,
2541  OpCodeMapValueType stepType,
2542  MutableNodeRefList& subQueryResults) const;
2543 
2544  OpCodeMapPositionType
2545  findChildren(
2546  XPathExecutionContext& executionContext,
2547  XalanNode* context,
2548  OpCodeMapPositionType opPos,
2549  OpCodeMapValueType stepType,
2550  MutableNodeRefList& subQueryResults) const;
2551 
2552  OpCodeMapPositionType
2553  findDescendants(
2554  XPathExecutionContext& executionContext,
2555  XalanNode* context,
2556  OpCodeMapPositionType opPos,
2557  OpCodeMapValueType stepType,
2558  MutableNodeRefList& subQueryResults) const;
2559 
2560  OpCodeMapPositionType
2561  findFollowing(
2562  XPathExecutionContext& executionContext,
2563  XalanNode* context,
2564  OpCodeMapPositionType opPos,
2565  OpCodeMapValueType stepType,
2566  MutableNodeRefList& subQueryResults) const;
2567 
2568  OpCodeMapPositionType
2569  findFollowingSiblings(
2570  XPathExecutionContext& executionContext,
2571  XalanNode* context,
2572  OpCodeMapPositionType opPos,
2573  OpCodeMapValueType stepType,
2574  MutableNodeRefList& subQueryResults) const;
2575 
2576  OpCodeMapPositionType
2577  findPreceeding(
2578  XPathExecutionContext& executionContext,
2579  XalanNode* context,
2580  OpCodeMapPositionType opPos,
2581  OpCodeMapValueType stepType,
2582  MutableNodeRefList& subQueryResults) const;
2583 
2584  OpCodeMapPositionType
2585  findPreceedingSiblings(
2586  XPathExecutionContext& executionContext,
2587  XalanNode* context,
2588  OpCodeMapPositionType opPos,
2589  OpCodeMapValueType stepType,
2590  MutableNodeRefList& subQueryResults) const;
2591 
2592  OpCodeMapPositionType
2593  findNamespace(
2594  XPathExecutionContext& executionContext,
2595  XalanNode* context,
2596  OpCodeMapPositionType opPos,
2597  OpCodeMapValueType stepType,
2598  MutableNodeRefList& subQueryResults) const;
2599 
2600  OpCodeMapPositionType
2601  findNodesOnUnknownAxis(
2602  XPathExecutionContext& executionContext,
2603  XalanNode* context,
2604  OpCodeMapPositionType opPos,
2605  OpCodeMapValueType stepType,
2606  MutableNodeRefList& subQueryResults) const;
2607 
2608  OpCodeMapPositionType
2609  predicates(
2610  XPathExecutionContext& executionContext,
2611  OpCodeMapPositionType opPos,
2612  MutableNodeRefList& subQueryResults) const;
2613 
2614  eMatchScore
2615  handleFoundIndex(
2616  XPathExecutionContext& executionContext,
2617  XalanNode* localContext,
2618  OpCodeMapPositionType startOpPos) const;
2619 
2620  eMatchScore
2621  handleFoundIndexPositional(
2622  XPathExecutionContext& executionContext,
2623  XalanNode* localContext,
2624  OpCodeMapPositionType startOpPos) const;
2625 
2626 private:
2627 
2628  void
2629  unknownOpCodeError(
2630  XalanNode* context,
2631  XPathExecutionContext& executionContext,
2632  OpCodeMapPositionType opPos) const;
2633 
2634  void
2635  notNodeSetError(
2636  XalanNode* context,
2637  XPathExecutionContext& executionContext) const;
2638 
2639  // Data members...
2640 
2641  /**
2642  *
2643  * Holds information about the current expression.
2644  *
2645  */
2646  XPathExpression m_expression;
2647 
2648  /**
2649  * A Locator for reporting errors.
2650  */
2651  const Locator* m_locator;
2652 
2653  /**
2654  * If true, the XPath can allocated XObjects in more
2655  * efficient ways, since its lifetime is guaranteed
2656  * to be at least that of the transformation.
2657  */
2658  bool m_inStylesheet;
2659 
2660  /**
2661  *
2662  * This is the table of installed functions.
2663  *
2664  */
2665  static FunctionTableType s_functions;
2666 
2667  static const XalanDOMString s_emptyString;
2668 };
2669 
2670 
2671 
2672 XALAN_CPP_NAMESPACE_END
2673 
2674 
2675 
2676 #endif // XPATH_HEADER_GUARD_1357924680
void execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext, XalanDOMString &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:381
void shrink()
Shrink internal tables.
Definition: XPath.hpp:186
XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType
Definition: XPath.hpp:68
const XObjectPtr execute(XPathExecutionContext &executionContext) const
Execute the XPath from the provided context.
Definition: XPath.hpp:469
void execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext, double &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:684
TokenQueueSizeType TokenQueuePositionType
static void installFunction(const XalanDOMString &funcName, const Function &func)
Install a built-in function.
Definition: XPath.hpp:915
double functionPosition(XalanNode *context, XPathExecutionContext &executionContext) const
Handle the built-in function "position".
Definition: XPath.hpp:2123
const XObjectPtr execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext) const
Execute the XPath from the provided context.
Definition: XPath.hpp:626
Local implementation of MutableNodeRefList.
void setInStylesheet(bool fValue)
Definition: XPath.hpp:1012
static double getNegativeInfinity()
Double value that represents negative infinity.
void execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext, bool &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:330
void group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, double &theResult) const
Execute an expression as a group.
Definition: XPath.hpp:1911
eMatchScore
Definition: XPath.hpp:86
const XObjectPtr extfunction(XalanNode *context, OpCodeMapPositionType, const XalanDOMString &theNamespace, const XalanDOMString &functionName, const Function::XObjectArgVectorType &argVec, XPathExecutionContext &executionContext) const
Handle an extension function.
Definition: XPath.hpp:2069
virtual const PrefixResolver * getPrefixResolver() const =0
Retrieve the resolver for namespaces.
XPathExpression::OpCodeMapPositionType OpCodeMapPositionType
Definition: XPath.hpp:70
bool null() const
Definition: XObject.hpp:937
bool functionBoolean(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "boolean".
Definition: XPath.hpp:2194
void group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, XalanDOMString &theResult) const
Execute an expression as a group.
Definition: XPath.hpp:1928
XPathExpression & getExpression()
Retrieve a reference to the current expression.
Definition: XPath.hpp:811
XPathExpression::TokenQueuePositionType TokenQueuePositionType
Definition: XPath.hpp:72
void setLocator(const Locator *theLocator)
Definition: XPath.hpp:1024
void execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext, FormatterListener &formatterListener, MemberFunctionPtr function) const
Execute the XPath from the provided context.
Definition: XPath.hpp:743
virtual const XObjectPtr extFunction(const XalanDOMString &theNamespace, const XalanDOMString &functionName, XalanNode *context, const XObjectArgVectorType &argVec, const Locator *locator)=0
Handle an extension function.
eTargetType getTargetType() const
Definition: XPath.hpp:131
Class to hold XObjectPtr return types.
Definition: XObject.hpp:883
static void getInstalledFunctionNames(OutputIteratorType theIterator)
Add the names for the installed functions to a vector strings.
Definition: XPath.hpp:994
Class defines a table of functions that can be called in XPath expresions.
MemoryManager & getMemoryManager()
Definition: XPath.hpp:175
TargetData(const XalanDOMChar *theString, eMatchScore thePriority, eTargetType theTargetType)
Definition: XPath.hpp:108
eMatchScore operator()(const XalanElement &context) const
Definition: XPath.hpp:1067
Definition: XPath.hpp:64
void execute(XPathExecutionContext &executionContext, XalanDOMString &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:539
static bool uninstallFunction(const XalanDOMChar *funcName)
Remove a named function from the function table.
Definition: XPath.hpp:957
XPathExecutionContext::CurrentNodePushAndPop CurrentNodePushAndPop
Definition: XPath.hpp:75
eMatchScore getDefaultPriority() const
Definition: XPath.hpp:125
static const FunctionTableType & getFunctionTable()
Retrieve the table of installed functions.
Definition: XPath.hpp:982
Local implementation of NodeRefList.
static void installFunction(const XalanDOMChar *funcName, const Function &func)
Install a built-in function.
Definition: XPath.hpp:930
void locationPath(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, MutableNodeRefList &theResult) const
Execute a location path.
Definition: XPath.hpp:1321
A SAX-based formatter interface for the XSL processor.
void addNodesInDocOrder(const XalanNodeList &nodelist, XPathExecutionContext &executionContext)
Copy NodeList members into this nodelist, adding in document order.
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
const XObjectPtr execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext, MutableNodeRefList &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:444
bool getInStylesheet() const
Definition: XPath.hpp:1006
static bool uninstallFunction(const XalanDOMString &funcName)
Remove a named function from the function table.
Definition: XPath.hpp:945
XPathExecutionContext::GetCachedString GetCachedString
Definition: XPath.hpp:73
const XObjectPtr predicate(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Evaluate a predicate.
Definition: XPath.hpp:892
virtual size_type getContextNodeListLength() const =0
XPathExecutionContext::PrefixResolverSetAndRestore PrefixResolverSetAndRestore
Definition: XPath.hpp:74
static const XalanDOMString & getNameOfNode(const XalanNode &n)
Retrieve the name of the node, taking into account the differences between the DOM and XSLT data mode...
const XObjectPtr group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Execute an expression as a group.
Definition: XPath.hpp:1878
void execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext, FormatterListener &formatterListener, MemberFunctionPtr function) const
Execute the XPath from the provided context.
Definition: XPath.hpp:407
XObjectPtr execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext, MutableNodeRefList &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:786
double functionLast(XPathExecutionContext &executionContext) const
Handle the built-in function "last".
Definition: XPath.hpp:2143
static double getMatchScoreValue(eMatchScore score)
Definition: XPath.hpp:828
virtual XalanNode * getCurrentNode() const =0
Retrieve the node currently being executed.
This class defines an interface for classes that resolve namespace prefixes to their URIs...
Class to hold XPath return types.
Definition: XObject.hpp:63
const Locator * getLocator() const
Definition: XPath.hpp:1018
void execute(XPathExecutionContext &executionContext, bool &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:490
void group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, FormatterListener &formatterListener, MemberFunctionPtr function) const
Execute an expression as a group.
Definition: XPath.hpp:1947
eMatchScore operator()(const XalanNode &context, XalanNode::NodeType nodeType) const
Definition: XPath.hpp:1057
const XalanDOMString & functionName(XalanNode *context) const
Handle the built-in function "name".
Definition: XPath.hpp:2215
static void destroyTable()
Definition: XPath.hpp:1000
static bool isInstalledFunction(const XalanDOMString &theFunctionName)
Whether the named function is installed in the function table.
Definition: XPath.hpp:969
void group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, bool &theResult) const
Execute an expression as a group.
Definition: XPath.hpp:1894
static double floor(double theValue)
Returns the floor of a number according to the XPath rules.
NodeRefListBase::size_type size_type
double functionCeiling(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "ceiling".
Definition: XPath.hpp:2323
NodeTester & operator=(const NodeTester &theRHS)
Definition: XPath.hpp:1073
virtual const NodeRefListBase & nodeset() const
Cast result object to a nodelist.
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
double functionNumber(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "number".
Definition: XPath.hpp:2285
double functionFloor(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "floor".
Definition: XPath.hpp:2306
static double round(double theValue)
Round a number according to the XPath rules.
static double number(bool theBoolean)
Static conversion function.
Definition: XObject.hpp:693
double functionNumber(XalanNode *context, XPathExecutionContext &executionContext) const
Handle the built-in function "number".
Definition: XPath.hpp:2267
const XPathExpression & getExpression() const
Retrieve a reference to the current expression.
Definition: XPath.hpp:822
XPathFunctionTable FunctionTableType
Definition: XPath.hpp:974
void group(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext, MutableNodeRefList &theResult) const
Execute an expression as a group.
Definition: XPath.hpp:1970
void execute(XPathExecutionContext &executionContext, FormatterListener &formatterListener, MemberFunctionPtr function) const
Execute the XPath from the provided context.
Definition: XPath.hpp:564
virtual size_type getContextNodeListPosition(const XalanNode &contextNode) const =0
const XObjectPtr execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext) const
Execute the XPath from the provided context.
Definition: XPath.hpp:306
[OP_XPATH] [length] {expression}
#define XALAN_XPATH_EXPORT
bool functionNot(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "not".
Definition: XPath.hpp:2175
OpCodeMapType::const_iterator OpCodeMapPositionType
void setDocumentOrder()
Set the known order of the nodes.
equals(const XalanDOMChar *theLHS, const XalanDOMChar *theRHS, XalanDOMString::size_type theLength)
Compare the contents of two arrays for equality.
void execute(XalanNode *context, const PrefixResolver &prefixResolver, const NodeRefListBase &contextNodeList, XPathExecutionContext &executionContext, double &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:355
OpCodeMapType::value_type OpCodeMapValueType
XalanVector< TargetData > TargetDataVectorType
Definition: XPath.hpp:145
void execute(XPathExecutionContext &executionContext, double &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:514
XPathExpression::OpCodeMapValueType OpCodeMapValueType
Definition: XPath.hpp:71
double functionRound(XalanNode *context, OpCodeMapPositionType opPos, XPathExecutionContext &executionContext) const
Handle the built-in function "round".
Definition: XPath.hpp:2340
void execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext, XalanDOMString &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:715
static double ceiling(double theValue)
Returns the ceiling of a number according to the XPath rules.
const XObjectPtr execute(XPathExecutionContext &executionContext, MutableNodeRefList &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:601
void execute(const PrefixResolver &prefixResolver, XPathExecutionContext &executionContext, bool &result) const
Execute the XPath from the provided context.
Definition: XPath.hpp:654
const XalanDOMChar * getString() const
Definition: XPath.hpp:119

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

Xalan-C++ XSLT Processor Version 1.11
Copyright © 1999-2012 The Apache Software Foundation.
All Rights Reserved.

Apache Logo