|
|
|
|
|
libxml2 Reference Manual |
|---|
xpath - XML Path Language implementation
API for the XML Path Language implementation XML Path Language implementation XPath is a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer
Author(s): Daniel Veillard
#define xmlXPathNodeSetGetLength(ns); #define XML_XPATH_CHECKNS; #define XML_XPATH_NOVAR; #define xmlXPathNodeSetItem(ns, index); #define xmlXPathNodeSetIsEmpty(ns); typedef enum xmlXPathObjectType; typedef xmlXPathVariable * xmlXPathVariablePtr; typedef struct _xmlXPathContext xmlXPathContext; typedef enum xmlXPathError; typedef struct _xmlXPathFunct xmlXPathFunct; typedef xmlXPathType * xmlXPathTypePtr; typedef struct _xmlXPathType xmlXPathType; typedef xmlNodeSet * xmlNodeSetPtr; typedef xmlXPathFunct * xmlXPathFuncPtr; typedef xmlXPathCompExpr * xmlXPathCompExprPtr; typedef struct _xmlXPathObject xmlXPathObject; typedef struct _xmlXPathCompExpr xmlXPathCompExpr; typedef xmlXPathContext * xmlXPathContextPtr; typedef xmlXPathParserContext * xmlXPathParserContextPtr; typedef struct _xmlNodeSet xmlNodeSet; typedef struct _xmlXPathVariable xmlXPathVariable; typedef xmlXPathObject * xmlXPathObjectPtr; typedef struct _xmlXPathAxis xmlXPathAxis; typedef xmlXPathAxis * xmlXPathAxisPtr; typedef struct _xmlXPathParserContext xmlXPathParserContext; int xmlXPathCastNodeSetToBoolean (xmlNodeSetPtr ns); typedef xmlXPathFunction xmlXPathFuncLookupFunc (void * ctxt,
const xmlChar * name,
const xmlChar * ns_uri); xmlXPathObjectPtr xmlXPathNodeEval (xmlNodePtr node,
const xmlChar * str,
xmlXPathContextPtr ctx); xmlChar * xmlXPathCastNodeToString (xmlNodePtr node); int xmlXPathIsNaN (double val); int xmlXPathContextSetCache (xmlXPathContextPtr ctxt,
int active,
int value,
int options); xmlXPathObjectPtr xmlXPathConvertString (xmlXPathObjectPtr val); int xmlXPathCompiledEvalToBoolean (xmlXPathCompExprPtr comp,
xmlXPathContextPtr ctxt); int xmlXPathIsInf (double val); long xmlXPathOrderDocElems (xmlDocPtr doc); xmlNodeSetPtr xmlXPathNodeSetCreate (xmlNodePtr val); double xmlXPathCastBooleanToNumber (int val); double xmlXPathCastNodeToNumber (xmlNodePtr node); double xmlXPathCastStringToNumber (const xmlChar * val); typedef xmlXPathObjectPtr xmlXPathAxisFunc (xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr cur); double xmlXPathCastToNumber (xmlXPathObjectPtr val); int xmlXPathCastStringToBoolean (const xmlChar * val); xmlChar * xmlXPathCastNumberToString (double val); typedef xmlXPathObjectPtr xmlXPathVariableLookupFunc (void * ctxt,
const xmlChar * name,
const xmlChar * ns_uri); void xmlXPathFreeObject (xmlXPathObjectPtr obj); int xmlXPathEvalPredicate (xmlXPathContextPtr ctxt,
xmlXPathObjectPtr res); void xmlXPathFreeContext (xmlXPathContextPtr ctxt); xmlXPathObjectPtr xmlXPathObjectCopy (xmlXPathObjectPtr val); void xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj); xmlXPathObjectPtr xmlXPathEval (const xmlChar * str,
xmlXPathContextPtr ctx); xmlChar * xmlXPathCastNodeSetToString (xmlNodeSetPtr ns); xmlXPathObjectPtr xmlXPathCompiledEval (xmlXPathCompExprPtr comp,
xmlXPathContextPtr ctx); xmlXPathObjectPtr xmlXPathEvalExpression (const xmlChar * str,
xmlXPathContextPtr ctxt); void xmlXPathInit (void); xmlXPathObjectPtr xmlXPathConvertBoolean (xmlXPathObjectPtr val); typedef int xmlXPathConvertFunc (xmlXPathObjectPtr obj,
int type); typedef void xmlXPathFunction (xmlXPathParserContextPtr ctxt,
int nargs); int xmlXPathCmpNodes (xmlNodePtr node1,
xmlNodePtr node2); xmlChar * xmlXPathCastToString (xmlXPathObjectPtr val); xmlXPathCompExprPtr xmlXPathCtxtCompile (xmlXPathContextPtr ctxt,
const xmlChar * str); typedef void xmlXPathEvalFunc (xmlXPathParserContextPtr ctxt,
int nargs); xmlChar * xmlXPathCastBooleanToString (int val); int xmlXPathSetContextNode (xmlNodePtr node,
xmlXPathContextPtr ctx); int xmlXPathCastNumberToBoolean (double val); void xmlXPathFreeNodeSet (xmlNodeSetPtr obj); void xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp); xmlXPathContextPtr xmlXPathNewContext (xmlDocPtr doc); xmlXPathObjectPtr xmlXPathConvertNumber (xmlXPathObjectPtr val); xmlXPathCompExprPtr xmlXPathCompile (const xmlChar * str); double xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns); int xmlXPathCastToBoolean (xmlXPathObjectPtr val);
#define xmlXPathNodeSetGetLength(ns);
Implement a functionality similar to the DOM NodeList.length. Returns the number of nodes in the node-set.
| ns: | a node-set |
#define xmlXPathNodeSetIsEmpty(ns);
Checks whether @ns is empty or not. Returns %TRUE if @ns is an empty node-set.
| ns: | a node-set |
#define xmlXPathNodeSetItem(ns, index);
Implements a functionality similar to the DOM NodeList.item(). Returns the xmlNodePtr at the given @index in @ns or NULL if @index is out of range (0 to length-1)
| ns: | a node-set |
| index: | index of a node in the set |
struct _xmlNodeSet {
int nodeNr : number of nodes in the set
int nodeMax : size of the array as allocated
xmlNodePtr * nodeTab : array of nodes in no particular order @@ with_ns to check whether nam
} xmlNodeSet;
xmlNodeSet * xmlNodeSetPtr;
struct _xmlXPathAxis {
const xmlChar * name : the axis name
xmlXPathAxisFunc func : the search function
} xmlXPathAxis;
xmlXPathAxis * xmlXPathAxisPtr;
struct _xmlXPathCompExpr {
The content of this structure is not made public by the API.
} xmlXPathCompExpr;
xmlXPathCompExpr * xmlXPathCompExprPtr;
struct _xmlXPathContext {
xmlDocPtr doc : The current document
xmlNodePtr node : The current node
int nb_variables_unused : unused (hash table)
int max_variables_unused : unused (hash table)
xmlHashTablePtr varHash : Hash table of defined variables
int nb_types : number of defined types
int max_types : max number of types
xmlXPathTypePtr types : Array of defined types
int nb_funcs_unused : unused (hash table)
int max_funcs_unused : unused (hash table)
xmlHashTablePtr funcHash : Hash table of defined funcs
int nb_axis : number of defined axis
int max_axis : max number of axis
xmlXPathAxisPtr axis : Array of defined axis the namespace nodes of the context node
xmlNsPtr * namespaces : Array of namespaces
int nsNr : number of namespace in scope
void * user : function to free extra variables
int contextSize : the context size
int proximityPosition : the proximity position extra stuff for XPointer
int xptr : is this an XPointer context?
xmlNodePtr here : for here()
xmlNodePtr origin : for origin() the set of namespace declarations in scope for the expre
xmlHashTablePtr nsHash : The namespaces hash table
xmlXPathVariableLookupFunc varLookupFunc : variable lookup func
void * varLookupData : variable lookup data Possibility to link in an extra item
void * extra : needed for XSLT The function name and URI when calling a function
const xmlChar * function
const xmlChar * functionURI : function lookup function and data
xmlXPathFuncLookupFunc funcLookupFunc : function lookup func
void * funcLookupData : function lookup data temporary namespace lists kept for walking the n
xmlNsPtr * tmpNsList : Array of namespaces
int tmpNsNr : number of namespaces in scope error reporting mechanism
void * userData : user specific data block
xmlStructuredErrorFunc error : the callback in case of errors
xmlError lastError : the last error
xmlNodePtr debugNode : the source node XSLT dictionary
xmlDictPtr dict : dictionary if any
int flags : flags to control compilation Cache for reusal of XPath objects
void * cache : Resource limits
unsigned long opLimit
unsigned long opCount
int depth
int maxDepth
int maxParserDepth
} xmlXPathContext;
xmlXPathContext * xmlXPathContextPtr;
enum xmlXPathError { XPATH_EXPRESSION_OK = 0 XPATH_NUMBER_ERROR = 1 XPATH_UNFINISHED_LITERAL_ERROR = 2 XPATH_START_LITERAL_ERROR = 3 XPATH_VARIABLE_REF_ERROR = 4 XPATH_UNDEF_VARIABLE_ERROR = 5 XPATH_INVALID_PREDICATE_ERROR = 6 XPATH_EXPR_ERROR = 7 XPATH_UNCLOSED_ERROR = 8 XPATH_UNKNOWN_FUNC_ERROR = 9 XPATH_INVALID_OPERAND = 10 XPATH_INVALID_TYPE = 11 XPATH_INVALID_ARITY = 12 XPATH_INVALID_CTXT_SIZE = 13 XPATH_INVALID_CTXT_POSITION = 14 XPATH_MEMORY_ERROR = 15 XPTR_SYNTAX_ERROR = 16 XPTR_RESOURCE_ERROR = 17 XPTR_SUB_RESOURCE_ERROR = 18 XPATH_UNDEF_PREFIX_ERROR = 19 XPATH_ENCODING_ERROR = 20 XPATH_INVALID_CHAR_ERROR = 21 XPATH_INVALID_CTXT = 22 XPATH_STACK_ERROR = 23 XPATH_FORBID_VARIABLE_ERROR = 24 XPATH_OP_LIMIT_EXCEEDED = 25 XPATH_RECURSION_LIMIT_EXCEEDED = 26 };
xmlXPathFunct * xmlXPathFuncPtr;
struct _xmlXPathFunct {
const