Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

TinyXPath::xpath_processor Class Reference

XPath execution class. More...

#include <xpath_processor.h>

Inheritance diagram for TinyXPath::xpath_processor:

Inheritance graph
[legend]
Collaboration diagram for TinyXPath::xpath_processor:

Collaboration graph
[legend]
List of all members.

Public Types

enum  {
  e_no_error, e_error_syntax, e_error_overflow, e_error_execution,
  e_error_stack
}

Public Member Functions

 xpath_processor (const TiXmlNode *XNp_source_tree, const char *cp_xpath_expr)
 Constructor.

virtual ~xpath_processor ()
expression_result er_compute_xpath ()
 Compute an XPath expression.

TIXML_STRING S_compute_xpath ()
 Compute an XPath expression and return the result as a string.

int i_compute_xpath ()
 Compute an XPath expression and return the result as an integer.

bool o_compute_xpath ()
double d_compute_xpath ()
unsigned u_compute_xpath_node_set ()
 Compute an XPath expression, and return the number of nodes in the resulting node set.

void v_get_xpath_base (unsigned u_order, const TiXmlBase *&XBp_res, bool &o_attribute)
 Get one of the XML nodes from the resulting node set. Can only be used after a call to u_compute_xpath_node_set.

TiXmlNodeXNp_get_xpath_node (unsigned u_order)
 Retrieves an XPath node from the node set. This assumes you know it's not an attribute.

TiXmlAttributeXAp_get_xpath_attribute (unsigned u_order)
 Retrieves an XPath attribute from the node set. This assumes you know it's an attribute.


Public Attributes

enum TinyXPath::xpath_processor:: { ... }  e_error

Protected Member Functions

virtual void v_action (xpath_construct, unsigned, unsigned, const char *)
 Callback from the XPath decoder : a rule has to be applied.

virtual int i_get_action_counter ()
 Internal use. Retrieves the current action counter.

void v_execute_stack ()
 Internal use. Executes the XPath expression. The executions starts at the end of the as_action_store list.

void v_pop_one_action (xpath_construct &xc_action, unsigned &u_sub, unsigned &u_ref, TIXML_STRING &S_literal)
 Retrieves one quadruplet from the action placeholder.

void v_execute_one (xpath_construct xc_rule, bool o_skip_only)
 Executes one XPath rule.

void v_execute_absolute_path (unsigned u_action_position, bool o_with_rel, bool o_everywhere)
 Execute a full set of absolute/relative/relative/.. computation.

void v_execute_step (int &i_relative_action, bool o_skip_only)
 One step execution.

bool o_check_predicate (const TiXmlElement *XEp_child, bool o_by_name)
 Spec extract :
A PredicateExpr is evaluated by evaluating the Expr and converting the result to a boolean.

void v_execute_function (TIXML_STRING &S_name, unsigned u_nb_arg, expression_result **erpp_arg)
 Execute an XPath function.

void v_function_ceiling (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath ceiling function.

void v_function_concat (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath concat function.

void v_function_contains (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath contains function.

void v_function_count (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath count function.

void v_function_false (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath false function.

void v_function_floor (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath floor function.

void v_function_last (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath last function.

void v_function_name (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath name function.

void v_function_normalize_space (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath normalize-space function.

void v_function_not (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath not function.

void v_function_position (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath position function.

void v_function_starts_with (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath starts-with function.

void v_function_string_length (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath sttring-length function.

void v_function_substring (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath substring function
Standard excerpt:
The substring function returns the substring of the first argument starting at the position specified in the second argument with length specified in the third argument.

void v_function_sum (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath sum function
Standard exerpt :
The sum function returns the sum, for each node in the argument node-set, of the result of converting the string-values of the node to a number.

void v_function_text (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath text function.

void v_function_true (unsigned u_nb_arg, expression_result **erpp_arg)
 XPath true function.

void v_function_equal (expression_result **erpp_arg)
 This function is for internal use : evaluation of an equality expression
Standard excerpt :
.

void v_function_not_equal (expression_result **erpp_arg)
 This function is for internal use : evaluation of a non-equality expression.

void v_function_equal_node_and_other (expression_result *erp_node, expression_result *erp_non)
 Utility function that evaluates the equality between a node set and a non-node set
.

void v_function_equal_2_node (expression_result *erp_node_set_, expression_result *erp_node_set_2)
void v_function_union (node_set &ns_1, node_set &ns_2)
 Union function.

void v_function_minus (expression_result **erpp_arg)
 XPath - function.

void v_function_plus (expression_result **erpp_arg)
 XPath + function.

void v_function_or (expression_result **erpp_arg)
 XPath or function.

void v_function_and (expression_result **erpp_arg)
 XPath and function.

void v_function_relational (expression_result **erpp_arg, unsigned u_sub)
 XPath relational comparison function.

void v_function_opposite ()
 This function, because it only operates on one argument retrieves it himself from the stack
It computes the mathematical opposite.

void v_function_mult (expression_result **erpp_arg, unsigned u_sub)
 XPath * function (arithmetic).

void v_order_tree ()
 flag that says if the tree has been ordered already.

void v_order_recurs (TiXmlNode *Np_base, int &i_current)
 Recursive ordering of an XML tree according to XPath's document order.

void v_push_int (int i_val, const char *cp_comment="")
void v_push_string (TIXML_STRING S_val)
void v_push_bool (bool o_val)
void v_push_double (double d_val)
void v_push_node_set (node_set *nsp_val)
bool o_pop_bool ()
int i_pop_int ()
TIXML_STRING S_pop_string ()
node_set ns_pop_node_set ()
void v_set_context (const TiXmlElement *XEp_in, bool o_by_name)
 Set the current context node for predicate evaluations.

const TiXmlElementXEp_get_context ()
void v_build_root ()
void v_remove_root ()
 Remove our fake root, and restore the original relationships of the node given to us as argument.


Protected Attributes

xpath_stack xs_stack
action_store as_action_store
TiXmlElementXEp_root
 Root, above the XML tree given as parameter to the xpath_processor object.

const TiXmlElementXEp_context
 Current context.

expression_result er_result
 The result of the XPath evaluation, for further node retrieving by v_get_xpath_base.

bool o_is_context_by_name
const TiXmlNodeXNp_caller_parent
const TiXmlNodeXNp_caller_prev
const TiXmlNodeXNp_caller_next
const TiXmlNodeXNp_base

Detailed Description

XPath execution class.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
e_no_error 
e_error_syntax 
e_error_overflow 
e_error_execution 
e_error_stack 


Constructor & Destructor Documentation

xpath_processor::xpath_processor const TiXmlNode XNp_source_tree,
const char *  cp_xpath_expr
 

Constructor.

Parameters:
XNp_source_tree  Source XML tree
cp_xpath_expr  XPath expression

virtual TinyXPath::xpath_processor::~xpath_processor  )  [inline, virtual]
 


Member Function Documentation

double xpath_processor::d_compute_xpath  ) 
 

expression_result xpath_processor::er_compute_xpath  ) 
 

Compute an XPath expression.

The executions stack need to contain 1 and only 1 element, otherwize it's not valid

int xpath_processor::i_compute_xpath  ) 
 

Compute an XPath expression and return the result as an integer.

int xpath_processor::i_get_action_counter  )  [protected, virtual]
 

Internal use. Retrieves the current action counter.

Implements TinyXPath::xpath_stream.

int TinyXPath::xpath_processor::i_pop_int  )  [inline, protected]
 

node_set TinyXPath::xpath_processor::ns_pop_node_set  )  [inline, protected]
 

bool xpath_processor::o_check_predicate const TiXmlElement XEp_child,
bool  o_by_name
[protected]
 

Spec extract :
A PredicateExpr is evaluated by evaluating the Expr and converting the result to a boolean.

If the result is a number, the result will be converted to true if the number is equal to the context position and will be converted to false otherwise; if the result is not a number, then the result will be converted as if by a call to the boolean function. Thus a location path para[3] is equivalent to para[position()=3].

bool xpath_processor::o_compute_xpath  ) 
 

bool TinyXPath::xpath_processor::o_pop_bool  )  [inline, protected]
 

TIXML_STRING xpath_processor::S_compute_xpath  ) 
 

Compute an XPath expression and return the result as a string.

TIXML_STRING TinyXPath::xpath_processor::S_pop_string  )  [inline, protected]
 

unsigned xpath_processor::u_compute_xpath_node_set  ) 
 

Compute an XPath expression, and return the number of nodes in the resulting node set.


Returns 0 if the result is not a node set

void xpath_processor::v_action xpath_construct  ,
unsigned  ,
unsigned  ,
const char * 
[protected, virtual]
 

Callback from the XPath decoder : a rule has to be applied.

Parameters:
xc_rule  XPath Rule
u_sub  Rule sub number
u_variable  Parameter, depends on the rule
cp_literal  Input literal, depends on the rule

Implements TinyXPath::xpath_stream.

void xpath_processor::v_build_root  )  [protected]
 

void xpath_processor::v_execute_absolute_path unsigned  u_action_position,
bool  o_with_rel,
bool  o_everywhere
[protected]
 

Execute a full set of absolute/relative/relative/.. computation.

Parameters:
u_action_position  Position of the placeholder after the rule
o_with_rel  true if there is some relative path
o_everywhere  true if it's a '//' path

void xpath_processor::v_execute_function TIXML_STRING &  S_name,
unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

Execute an XPath function.

The arguments are in normal order in erpp_arg
Calls one of the following :

  • v_function_ceiling
  • v_function_concat
  • v_function_contains
  • v_function_count
  • v_function_false
  • v_function_floor
  • v_function_last
  • v_function_name
  • v_function_normalize_space
  • v_function_not
  • v_function_position
  • v_function_starts_with
  • v_function_string_length
  • v_function_substring
  • v_function_sum
  • v_function_true
Parameters:
S_name  Function name
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_execute_one xpath_construct  xc_rule,
bool  o_skip_only
[protected]
 

Executes one XPath rule.

Compute each argument, and store them in a temporary list

Parameters:
xc_rule  Rule number
o_skip_only  True if we only need to skip rules and not act on the data stack

void xpath_processor::v_execute_stack  )  [protected]
 

Internal use. Executes the XPath expression. The executions starts at the end of the as_action_store list.

void xpath_processor::v_execute_step int &  i_relative_action,
bool  o_skip_only
[protected]
 

One step execution.

Initialize the source node set if it's the first step of a path

Parameters:
i_relative_action  Path position : -1 if first in a '//' path, 0 if first in a '/' path, > 0 if followers

void xpath_processor::v_function_and expression_result **  erpp_arg  )  [protected]
 

XPath and function.

void xpath_processor::v_function_ceiling unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath ceiling function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_concat unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath concat function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_contains unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath contains function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_count unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath count function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_equal expression_result **  erpp_arg  )  [protected]
 

This function is for internal use : evaluation of an equality expression
Standard excerpt :
.

If both objects to be compared are node-sets, then the comparison will be true if and only if there is a node in the first node-set and a node in the second node-set such that the result of performing the comparison on the string-values of the two nodes is true.

If one object to be compared is a node-set and the other is a number, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the number to be compared and on the result of converting the string-value of that node to a number using the number function is true.

If one object to be compared is a node-set and the other is a string, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the string-value of the node and the other string is true.

If one object to be compared is a node-set and the other is a boolean, then the comparison will be true if and only if the result of performing the comparison on the boolean and on the result of converting the node-set to a boolean using the boolean function is true.

When neither object to be compared is a node-set and the operator is = or !=, then the objects are compared by converting them to a common type as follows and then comparing them.

  • If at least one object to be compared is a boolean, then each object to be compared is converted to a boolean as if by applying the boolean function.
  • Otherwise, if at least one object to be compared is a number, then each object to be compared is converted to a number as if by applying the number function.
  • Otherwise, both objects to be compared are converted to strings as if by applying the string function. The = comparison will be true if and only if the objects are equal; the != comparison will be true if and only if the objects are not equal.
  • Numbers are compared for equality according to IEEE 754.
  • Two booleans are equal if either both are true or both are false.
  • Two strings are equal if and only if they consist of the same sequence of UCS characters.

void xpath_processor::v_function_equal_2_node expression_result erp_node_set_,
expression_result erp_node_set_2
[protected]
 

Todo:
: Implement this function. We don't compare 2 node sets yet

void xpath_processor::v_function_equal_node_and_other expression_result erp_node_set,
expression_result erp_non
[protected]
 

Utility function that evaluates the equality between a node set and a non-node set
.

Standard excerpt :
If one object to be compared is a node-set and the other is a number, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the number to be compared and on the result of converting the string-value of that node to a number using the number function is true.

If one object to be compared is a node-set and the other is a string, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the string-value of the node and the other string is true.

If one object to be compared is a node-set and the other is a boolean, then the comparison will be true if and only if the result of performing the comparison on the boolean and on the result of converting the node-set to a boolean using the boolean function is true.

void xpath_processor::v_function_false unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath false function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_floor unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath floor function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_last unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath last function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_minus expression_result **  erpp_arg  )  [protected]
 

XPath - function.

void xpath_processor::v_function_mult expression_result **  erpp_arg,
unsigned  u_sub
[protected]
 

XPath * function (arithmetic).

void xpath_processor::v_function_name unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath name function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_normalize_space unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath normalize-space function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_not unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath not function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_not_equal expression_result **  erpp_arg  )  [protected]
 

This function is for internal use : evaluation of a non-equality expression.

void xpath_processor::v_function_opposite  )  [protected]
 

This function, because it only operates on one argument retrieves it himself from the stack
It computes the mathematical opposite.

void xpath_processor::v_function_or expression_result **  erpp_arg  )  [protected]
 

XPath or function.

void xpath_processor::v_function_plus expression_result **  erpp_arg  )  [protected]
 

XPath + function.

void xpath_processor::v_function_position unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath position function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_relational expression_result **  erpp_arg,
unsigned  u_sub
[protected]
 

XPath relational comparison function.

void xpath_processor::v_function_starts_with unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath starts-with function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_string_length unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath sttring-length function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_substring unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath substring function
Standard excerpt:
The substring function returns the substring of the first argument starting at the position specified in the second argument with length specified in the third argument.

For example, substring("12345",2,3) returns "234". If the third argument is not specified, it returns the substring starting at the position specified in the second argument and continuing to the end of the string. For example, substring("12345",2) returns "2345".

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_sum unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath sum function
Standard exerpt :
The sum function returns the sum, for each node in the argument node-set, of the result of converting the string-values of the node to a number.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_text unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath text function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_true unsigned  u_nb_arg,
expression_result **  erpp_arg
[protected]
 

XPath true function.

Parameters:
u_nb_arg  Nb of arguments
erpp_arg  Argument list

void xpath_processor::v_function_union node_set ns_1,
node_set ns_2
[protected]
 

Union function.

void xpath_processor::v_get_xpath_base unsigned  u_order,
const TiXmlBase *&  XBp_res,
bool &  o_attribute
 

Get one of the XML nodes from the resulting node set. Can only be used after a call to u_compute_xpath_node_set.

Parameters:
u_order  Order of the node. Must be between 0 and the number of nodes - 1
XBp_res  Output node
o_attrib  True if the output node is an attribute, false if it's a TiXmlNode

void xpath_processor::v_order_recurs TiXmlNode Np_base,
int &  i_current
[protected]
 

Recursive ordering of an XML tree according to XPath's document order.


The result is stored as an integer in the void * pointer managed by TiXmlNode::SetUserData / TiXmlNode::GetUserData

void xpath_processor::v_order_tree  )  [protected]
 

flag that says if the tree has been ordered already.

This is a rather slow process, so we only do it if needed

void xpath_processor::v_pop_one_action xpath_construct xc_action,
unsigned &  u_sub,
unsigned &  u_ref,
TIXML_STRING &  S_literal
[protected]
 

Retrieves one quadruplet from the action placeholder.

Parameters:
xc_action  Next rule on placeholder
u_sub  Sub rule
u_ref  Rule optional parameter
S_literal  Rule optional string

void TinyXPath::xpath_processor::v_push_bool bool  o_val  )  [inline, protected]
 

void TinyXPath::xpath_processor::v_push_double double  d_val  )  [inline, protected]
 

void TinyXPath::xpath_processor::v_push_int int  i_val,
const char *  cp_comment = ""
[inline, protected]
 

void TinyXPath::xpath_processor::v_push_node_set node_set nsp_val  )  [inline, protected]
 

void TinyXPath::xpath_processor::v_push_string TIXML_STRING  S_val  )  [inline, protected]
 

void xpath_processor::v_remove_root  )  [protected]
 

Remove our fake root, and restore the original relationships of the node given to us as argument.

void xpath_processor::v_set_context const TiXmlElement XEp_in,
bool  o_by_name
[protected]
 

Set the current context node for predicate evaluations.

Parameters:
XEp_in  Context node
o_by_name  true if the current node search is by name, false if it's a *

TiXmlAttribute * xpath_processor::XAp_get_xpath_attribute unsigned  u_order  ) 
 

Retrieves an XPath attribute from the node set. This assumes you know it's an attribute.

Parameters:
u_order  Order of the node. Must be between 0 and the number of nodes - 1

const TiXmlElement* TinyXPath::xpath_processor::XEp_get_context  )  [inline, protected]
 

TiXmlNode * xpath_processor::XNp_get_xpath_node unsigned  u_order  ) 
 

Retrieves an XPath node from the node set. This assumes you know it's not an attribute.

Parameters:
u_order  Order of the node. Must be between 0 and the number of nodes - 1


Member Data Documentation

action_store TinyXPath::xpath_processor::as_action_store [protected]
 

enum { ... } TinyXPath::xpath_processor::e_error
 

expression_result TinyXPath::xpath_processor::er_result [protected]
 

The result of the XPath evaluation, for further node retrieving by v_get_xpath_base.

bool TinyXPath::xpath_processor::o_is_context_by_name [protected]
 

const TiXmlElement* TinyXPath::xpath_processor::XEp_context [protected]
 

Current context.

TiXmlElement* TinyXPath::xpath_processor::XEp_root [protected]
 

Root, above the XML tree given as parameter to the xpath_processor object.

const TiXmlNode* TinyXPath::xpath_processor::XNp_base [protected]
 

const TiXmlNode* TinyXPath::xpath_processor::XNp_caller_next [protected]
 

const TiXmlNode* TinyXPath::xpath_processor::XNp_caller_parent [protected]
 

const TiXmlNode* TinyXPath::xpath_processor::XNp_caller_prev [protected]
 

xpath_stack TinyXPath::xpath_processor::xs_stack [protected]
 


The documentation for this class was generated from the following files:
Generated for TinyXPath by doxygen SourceForge Logo