a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xpath.c: XML Path Language implementation
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * XPath is a language for addressing parts of an XML document,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * designed to be used by both XSLT and XPointer
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Reference: W3C Recommendation 16 November 1999
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Public reference:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * See Copyright for the status of this software
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Author: daniel@veillard.com
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Unimplemented block at %s:%d\n", \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* XP_OPTIMIZED_NON_ELEM_COMPARISON:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* If defined, this will use xmlXPathCmpNodesExt() instead of
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* xmlXPathCmpNodes(). The new function is optimized comparison of
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* non-element nodes; actually it will speed up comparison only if
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* xmlXPathOrderDocElems() was called in order to index the elements of
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* a tree in document order; Libxslt does such an indexing, thus it will
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* benefit from this optimization.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* XP_OPTIMIZED_FILTER_FIRST:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* If defined, this will optimize expressions like "key('foo', 'val')[b][1]"
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* in a way, that it stop evaluation at the first node.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* XP_DEBUG_OBJ_USAGE:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* Internal flag to enable tracking of how much XPath objects have been
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define XP_DEBUG_OBJ_USAGE */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * There are a few spots where some tests are done which depend upon ascii
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * data. These should be enhanced for full UTF8 support (see particularly
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Floating point stuff *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * The lack of portability of this section of the libc is annoying !
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsyncstatic double xmlXPathNZERO = 0; /* not exported from headers */
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * xmlXPathInit:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Initialize the XPath environment
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathIsNaN:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @val: a double value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Provides a portable isnan() function to detect whether a double
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * is a NotaNumber. Based on trio code
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns 1 if the value is a NaN, 0 otherwise
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathIsInf:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @val: a double value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Provides a portable isinf() function to detect whether a double
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * is a +Infinite or -Infinite. Based on trio code
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns 1 vi the value is +Infinite, -1 if -Infinite, 0 otherwise
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync#endif /* SCHEMAS or XPATH */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathGetSign:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @val: a double value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Provides a portable function to detect the sign of a double
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Modified from trio code
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns 1 if the value is Negative, 0 if positive
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * TODO: when compatibility allows remove all "fake node libxslt" strings
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the test should just be name[0] = ' '
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define DEBUG */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define DEBUG_STEP */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define DEBUG_STEP_NTH */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define DEBUG_EXPR */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define DEBUG_EVAL_COUNTS */
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncstatic xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Optimizer is disabled only when threaded apps are detected while
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the library ain't compiled for thread safety.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Error handling routines *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * XP_ERRORNULL:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @X: the error code
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Macro to raise an XPath error and return NULL.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * The array xmlXPathErrorMessages corresponds to the enum xmlXPathError
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Number encoding\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Unfinished literal\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Start of literal\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Expected $ for variable reference\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Undefined variable\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid predicate\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid expression\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Missing closing curly brace\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Unregistered function\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid operand\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid type\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid number of arguments\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid context size\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid context position\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Memory allocation error\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Syntax error\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Resource error\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Sub resource error\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Undefined namespace prefix\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Encoding error\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Char out of XML range\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Invalid or incomplete context\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Stack usage errror\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "?? Unknown error ??\n" /* Must be last in the list! */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathErrMemory:
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * @ctxt: an XPath context
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * @extra: extra informations
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Handle a redefinition of attribute error
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Memory allocation failed\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathPErrMemory:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: an XPath parser context
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @extra: extra informations
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Handle a redefinition of attribute error
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathErr:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: a XPath parser context
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @error: the error code
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Handle an XPath error
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync /* cleanup current last error */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ctxt->context->lastError.node = ctxt->context->debugNode;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPatherror:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: the XPath Parser context
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @file: the file name
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @line: the line number
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @no: the error number
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Formats an error message.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Utilities *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xsltPointerList:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Pointer-list for various purposes.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* TODO: Since such a list-handling is used in xmlschemas.c and libxslt
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* and here, we should make the functions public.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync initialSize * sizeof(void *));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "xmlPointerListCreate: allocating item\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return(-1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "xmlPointerListCreate: re-allocating item\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return(-1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xsltPointerListCreate:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Creates an xsltPointerList structure.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns a xsltPointerList structure or NULL in case of an error.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "xmlPointerListCreate: allocating item\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xsltPointerListFree:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Frees the xsltPointerList structure. This does not free
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * the content of the list.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Parser Types *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Types are private:
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef enum {
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef enum {
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef enum {
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef enum {
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync xmlXPathOp op; /* The identifier of the operation */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int nbStep; /* Number of steps in this expression */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int maxStep; /* Maximum number of steps allocated */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathStepOp *steps; /* ops for computation of this expression */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlDictPtr dict; /* the dictionnary to use if any */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Forward declarations *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Parser Type functions *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathNewCompExpr:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Create a new Xpath component
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns the newly allocated xmlXPathCompExprPtr or NULL in case of error
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync cur = (xmlXPathCompExprPtr) xmlMalloc(sizeof(xmlXPathCompExpr));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync cur->steps = (xmlXPathStepOp *) xmlMalloc(cur->maxStep *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync memset(cur->steps, 0, cur->maxStep * sizeof(xmlXPathStepOp));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathFreeCompExpr:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @comp: an XPATH comp
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Free up the memory allocated by @comp
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathCompExprAdd:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @comp: the compiled expression
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ch1: first child index
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ch2: second child index
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @op: an op
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value: the first int value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value2: the second int value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value3: the third int value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value4: the first string value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value5: the second string value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Add a step to an XPath Compiled Expression
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns -1 in case of failure, the index otherwise
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int value2, int value3, void *value4, void *value5) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return(-1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ((op == XPATH_OP_FUNCTION) || (op == XPATH_OP_VARIABLE) ||
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathCompSwap:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @comp: the compiled expression
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @op: operation index
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Swaps 2 operations in the compiled expression
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Since this manipulates possibly shared variables, this is
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * disabled if one detects that the library is used in a multithreaded
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * application
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define PUSH_FULL_EXPR(op, op1, op2, val, val2, val3, val4, val5) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define PUSH_LONG_EXPR(op, val, val2, val3, val4, val5) \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * XPath object cache structures *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* #define XP_DEFAULT_CACHE_ON */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#define XP_HAS_CACHE(c) ((c != NULL) && ((c)->cache != NULL))
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef struct _xmlXPathContextCache xmlXPathContextCache;
a180a41bba1d50822df23fff0099e90b86638b89vboxsynctypedef xmlXPathContextCache *xmlXPathContextCachePtr;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlPointerListPtr nodesetObjs; /* contains xmlXPathObjectPtr */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlPointerListPtr stringObjs; /* contains xmlXPathObjectPtr */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlPointerListPtr booleanObjs; /* contains xmlXPathObjectPtr */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlPointerListPtr numberObjs; /* contains xmlXPathObjectPtr */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlPointerListPtr miscObjs; /* contains xmlXPathObjectPtr */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Debugging related functions *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync "Internal error at %s:%d\n", \
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Set contains %d nodes:\n", cur->nodeNr);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNode(output, cur->nodeTab[i], depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync if ((cur == NULL) || (cur->nodeNr == 0) || (cur->nodeTab[0] == NULL)) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif /* LIBXML_XPTR_ENABLED */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathDebugDumpObject:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @output: the FILE * to dump the output
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @cur: the object to inspect
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @depth: indentation level
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Dump the content of the object for debugging purposes
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNodeSet(output, cur->nodesetval, depth);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is an XSLT value tree :\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpValueTree(output, cur->nodesetval, depth);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is a number : Infinity\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is a number : -Infinity\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync } else if (cur->floatval == 0 && xmlXPathGetSign(cur->floatval) != 0) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is a number : %0g\n", cur->floatval);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is a point : index %d in node", cur->index);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user, depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ((cur->user2 == cur->user) && (cur->index == cur->index2))) {
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Object is a collapsed range :\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user2,
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathTestVal test = (xmlXPathTestVal)op->value2;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathTypeVal type = (xmlXPathTypeVal)op->value3;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathObjectPtr object = (xmlXPathObjectPtr) op->value4;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "FUNCTION %s(%d args)", name, nbargs);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync case XPATH_OP_PREDICATE: fprintf(output, "PREDICATE"); break;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync case XPATH_OP_FILTER: fprintf(output, "FILTER"); break;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync case XPATH_OP_RANGETO: fprintf(output, "RANGETO"); break;
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch1], depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpStepOp(output, comp, &comp->steps[op->ch2], depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathDebugDumpCompExpr:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @output: the FILE * for the output
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @comp: the precompiled XPath expression
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @depth: the indentation level.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Dumps the tree of the compiled XPath expression.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync fprintf(output, "Compiled Expression : %d elements\n",
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugDumpStepOp(output, comp, &comp->steps[i], depth + 1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync* XPath object usage related debugging variables.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* REVISIT TODO: Make this static when committing */
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/* REVISIT TODO: Make this static when committing */
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int reqAll, reqNodeset, reqString, reqBool, reqNumber,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int caAll = 0, caNodeset = 0, caString = 0, caBool = 0,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync int reAll = 0, reNodeset = 0, reString = 0, reBool = 0,
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalAll);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalNodeset);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# max : %d\n", xmlXPathDebugObjMaxNodeset);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalString);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalBool);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalNumber);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalXSLTTree);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# max : %d\n", xmlXPathDebugObjMaxXSLTTree);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# created: %d\n", xmlXPathDebugObjTotalUndefined);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync printf("# max : %d\n", xmlXPathDebugObjMaxUndefined);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif /* XP_DEBUG_OBJ_USAGE */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync#endif /* LIBXML_DEBUG_ENABLED */
a180a41bba1d50822df23fff0099e90b86638b89vboxsync/************************************************************************
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * XPath object caching *
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ************************************************************************/
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathNewCache:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Create a new object cache
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns the xmlXPathCache just allocated.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync ret = (xmlXPathContextCachePtr) xmlMalloc(sizeof(xmlXPathContextCache));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathErrMemory(NULL, "creating object cache\n");
a180a41bba1d50822df23fff0099e90b86638b89vboxsync memset(ret, 0 , (size_t) sizeof(xmlXPathContextCache));
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Note that it is already assured that we don't need to
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * look out for namespace nodes in the node-set.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathContextSetCache:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: the XPath context
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @active: enables/disables (creates/frees) the cache
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @value: a value with semantics dependant on @options
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @options: options (currently only the value 0 is used)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Creates/frees an object cache on the XPath context.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * If activates XPath objects (xmlXPathObject) will be cached internally
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * to be reused.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @options:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * 0: This will set the XPath object caching:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * This will set the maximum number of XPath objects
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * to be cached per slot
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * There are 5 slots for: node-set, string, number, boolean, and
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * misc objects. Use <0 for the default number (100).
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Other values for @options have currently no effect.
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * Returns 0 if the setting succeeded, and -1 on API or internal errors.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync return(-1);
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync return(-1);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathCacheWrapNodeSet:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: the XPath context
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * @val: the NodePtr value
6e9aa255e3376b2da5824c09c4c62bc233463bfevboxsync * This is the cached version of xmlXPathWrapNodeSet().
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Wrap the Nodeset @val in a new xmlXPathObjectPtr
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns the created or reused object.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * xmlXPathCacheWrapString:
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @ctxt: the XPath context
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * @val: the xmlChar * value
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * This is the cached version of xmlXPathWrapString().
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Wraps the @val string into an XPath object.
a180a41bba1d50822df23fff0099e90b86638b89vboxsync * Returns the created or reused object.
a180a41bba1d50822df23fff0099e90b86638b89vboxsyncxmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
a180a41bba1d50822df23fff0099e90b86638b89vboxsync xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
if (val) {
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
static xmlXPathObjectPtr
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
return(val);
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
TODO;
static xmlXPathObjectPtr
return(NULL);
case XPATH_NODESET:
case XPATH_STRING:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
static xmlXPathObjectPtr
return(val);
return(ret);
static xmlXPathObjectPtr
return(val);
return(ret);
return(ret);
return (NULL);
return (NULL);
return (ret);
return(ret);
return(ret);
xmlChar *
return(NULL);
return(ret);
return(NULL);
return(NULL);
return(ret);
return(NULL);
return(NULL);
return(ret);
else i += xmlCopyChar(l,&b[i],v)
#ifndef DBL_DIG
#ifndef DBL_EPSILON
if (value == 0) {
*ptr = 0;
} else if (buffersize > 0) {
ptr--;
*ptr = 0;
if (integer_place > 0)
ptr++;
return(count);
* Compare two nodes w.r.t document order
if (attr1 != 0) {
depth2++;
depth1++;
depth1--;
depth2--;
* Compare two nodes w.r.t document order.
case XML_ELEMENT_NODE:
goto turtle_comparison;
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
case XML_PI_NODE: {
precedence1 = 0;
case XML_NAMESPACE_DECL:
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
case XML_PI_NODE: {
precedence2 = 0;
case XML_NAMESPACE_DECL:
if (misc) {
while (cur) {
while (cur) {
depth2++;
depth1++;
depth1--;
depth2--;
j = i - incr;
j -= incr;
static xmlNodePtr
return(NULL);
return(NULL);
return(NULL);
sizeof(xmlNodePtr));
return(NULL);
return(ret);
static xmlNodeSetPtr
return(NULL);
return(NULL);
return(ret);
sizeof(xmlNodePtr));
sizeof(xmlNodePtr));
sizeof(xmlNodePtr));
sizeof(xmlNodePtr));
sizeof(xmlNodePtr));
sizeof(xmlNodePtr));
return(NULL);
return(val1);
skip = 0;
for (j = 0; j < initNr; j++) {
if (skip)
sizeof(xmlNodePtr));
return(NULL);
sizeof(xmlNodePtr));
return(NULL);
return(val1);
static xmlNodeSetPtr
sizeof(xmlNodePtr));
return(NULL);
sizeof(xmlNodePtr));
return(NULL);
return(val1);
static xmlNodeSetPtr
int hasNullEntries)
return(NULL);
for (j = 0; j < initNbSet1; j++) {
goto skip_node;
goto skip_node;
return(NULL);
return(NULL);
return(set1);
static xmlNodeSetPtr
int hasNullEntries)
return(set1);
return(NULL);
return(NULL);
return(NULL);
return(set1);
#ifdef DEBUG
else if (hasNsNodes) {
else if ((hasNsNodes)) {
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return (ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
#ifdef XP_DEBUG_OBJ_USAGE
return(nodes1);
return(ret);
for (i = 0; i < l1; i++) {
return(ret);
return(ret);
return(ret);
for (i = 0; i < l1; i++) {
return(ret);
return(nodes);
return(ret);
return(nodes);
return(nodes);
return(ret);
return(ret);
return(nodes1);
return(nodes1);
return(nodes);
return(ret);
return(ret);
return(nodes1);
return(nodes1);
xmlXPathFunction f) {
if (f == NULL)
void *funcCtxt) {
return (NULL);
return(ret);
return(NULL);
return(NULL);
return(ret);
return(NULL);
return(ret);
(void *) value,
return(NULL);
return(ret);
return(NULL);
return(NULL);
return(NULL);
const xmlChar *
return(NULL);
return(NULL);
#ifdef XML_XML_NAMESPACE
return(XML_XML_NAMESPACE);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
return(ret);
return(NULL);
return(NULL);
#ifdef XP_DEBUG_OBJ_USAGE
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_STRING:
case XPATH_XSLT_TREE:
case XPATH_NODESET:
case XPATH_LOCATIONSET:
#ifdef LIBXML_XPTR_ENABLED
case XPATH_USERS:
case XPATH_UNDEFINED:
return(ret);
#ifdef LIBXML_XPTR_ENABLED
#ifdef XP_DEBUG_OBJ_USAGE
case XPATH_NODESET:
case XPATH_XSLT_TREE:
goto obj_cached;
case XPATH_STRING:
goto obj_cached;
case XPATH_BOOLEAN:
goto obj_cached;
case XPATH_NUMBER:
goto obj_cached;
#ifdef LIBXML_XPTR_ENABLED
case XPATH_LOCATIONSET:
goto free_obj;
goto free_obj;
goto free_obj;
#ifdef XP_DEBUG_OBJ_USAGE
#ifdef XP_DEBUG_OBJ_USAGE
xmlChar *
if (val)
return(ret);
xmlChar *
return(ret);
xmlChar *
return(ret);
xmlChar *
xmlChar *
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_BOOLEAN:
case XPATH_NUMBER: {
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
return(ret);
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
return(val);
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
TODO;
if (val)
return(xmlXPathNAN);
return(xmlXPathNAN);
return(ret);
return(xmlXPathNAN);
return(ret);
return(xmlXPathNAN);
case XPATH_UNDEFINED:
#ifdef DEGUB_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_NUMBER:
case XPATH_BOOLEAN:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
TODO;
return(ret);
return(val);
return(ret);
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
ret = 0;
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_NUMBER:
case XPATH_BOOLEAN:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
TODO;
ret = 0;
return(ret);
return(xmlXPathNewBoolean(0));
return(val);
return(ret);
return(NULL);
#ifdef XP_DEFAULT_CACHE_ON
return(NULL);
return(ret);
return(NULL); \
return(NULL); \
return(NULL);
return(NULL);
return(ret);
static xmlXPathParserContextPtr
return(NULL);
return(NULL);
return(ret);
#ifdef XPATH_STREAMING
case XML_COMMENT_NODE:
case XML_PI_NODE:
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
if (string[0] == 0)
return(((unsigned int) string[0]) +
case XML_NAMESPACE_DECL:
if (string[0] == 0)
return(((unsigned int) string[0]) +
case XML_ATTRIBUTE_NODE:
case XML_ELEMENT_NODE:
case XML_COMMENT_NODE:
case XML_PI_NODE:
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
case XML_NAMESPACE_DECL:
return(((unsigned int) string[0]) +
return(ret);
if (string[0] == 0)
return(((unsigned int) string[0]) +
if (ret)
return(ret);
if (ret)
return(ret);
if (init == 0) {
if (ret)
if (ret)
return(ret);
case XPATH_NUMBER:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_BOOLEAN:
if (neq)
if (neq)
} else if (neq) {
} else if (neq)
if (!xmlXPathIsNaN(v)) {
if ((!neq) && (v==f)) {
} else if ((neq) && (v!=f)) {
if (neq)
return(ret);
if (neq == 0)
if (neq) {
if (ret)
if (ret)
return(ret);
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_BOOLEAN:
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_BOOLEAN:
#ifdef DEBUG_EXPR
case XPATH_NUMBER:
case XPATH_STRING:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_NUMBER:
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_BOOLEAN:
case XPATH_STRING:
case XPATH_NUMBER:
ret = 0;
ret = 0;
ret = 0;
ret = 0;
ret = 0;
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_BOOLEAN:
case XPATH_STRING:
case XPATH_NUMBER:
ret = 0;
ret = 0;
ret = 0;
ret = 0;
ret = 0;
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
return(ret);
#ifdef DEBUG_EXPR
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_STRING:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
return(ret);
#ifdef DEBUG_EXPR
case XPATH_UNDEFINED:
#ifdef DEBUG_EXPR
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_STRING:
case XPATH_USERS:
case XPATH_POINT:
case XPATH_RANGE:
case XPATH_LOCATIONSET:
return(ret);
return(ret);
ret=0;
ret = 0;
ret = 0;
ret = 0;
ret = 0;
return(ret);
else if (val == 0) {
if (arg2 == 0)
return(NULL);
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
case XML_DTD_NODE:
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_ATTRIBUTE_NODE:
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return(NULL);
return(NULL);
return(NULL);
static xmlNodePtr
case XML_ELEMENT_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_ENTITY_NODE:
return(cur);
return(cur);
return(NULL);
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
return(NULL);
return(NULL);
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_CDATA_SECTION_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_XINCLUDE_END:
return(NULL);
return(cur);
return(NULL);
static xmlNodePtr
return(NULL);
case XML_ELEMENT_NODE:
case XML_XINCLUDE_START:
case XML_DOCUMENT_FRAG_NODE:
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
return(contextNode);
return(NULL);
return(NULL);
case XML_ELEMENT_NODE:
case XML_XINCLUDE_START:
case XML_DOCUMENT_FRAG_NODE:
return(cur);
case XML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
return(cur);
return(NULL);
goto next_sibling;
return(NULL);
return(NULL);
return(NULL);
return(cur);
return(cur);
return(cur);
return(cur);
return(NULL);
return(NULL);
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
case XML_DTD_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
case XML_ENTITY_DECL:
return(NULL);
case XML_ATTRIBUTE_NODE: {
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
return(NULL);
case XML_NAMESPACE_DECL: {
return(NULL);
return(NULL);
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_DTD_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_NOTATION_NODE:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return(NULL);
case XML_ATTRIBUTE_NODE: {
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
return(NULL);
case XML_NAMESPACE_DECL: {
return(NULL);
return(NULL);
return(NULL);
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
case XML_DTD_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return(NULL);
return(NULL);
case XML_ATTRIBUTE_NODE: {
case XML_NAMESPACE_DECL: {
return(NULL);
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
return(NULL);
return(NULL);
return(NULL);
return(NULL);
return(NULL);
return(NULL);
return(NULL);
return(cur);
return(NULL);
return (NULL);
return (cur);
return (NULL);
return (NULL);
return (cur);
static xmlNodePtr
return (NULL);
return (NULL);
return (NULL);
return (NULL);
return (cur);
return (cur);
return(NULL);
return(NULL);
return(NULL);
return(NULL);
CHECK_ARITY(0);
#ifdef DEBUG_EXPR
CHECK_ARITY(0);
#ifdef DEBUG_EXPR
static xmlNodeSetPtr
while (*cur != 0) {
cur++;
return(ret);
tokens =
if (nargs == 0) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
case XML_NAMESPACE_DECL:
if (nargs == 0) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
if (nargs == 0) {
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
NULL, 0);
if (nargs == 0) {
if (nargs == 0) {
nargs--;
while (nargs > 0) {
nargs--;
le = (double)m;
i = (int) in;
l = (int) le;
if (target) {
if (point) {
if (target) {
if (point) {
if (nargs == 0) {
source++;
blank = 0;
while (*source) {
if (blank) {
blank = 0;
source++;
if (target) {
if (offset >= 0) {
if (point)
cptr++;
CHECK_ARITY(0);
CHECK_ARITY(0);
for (i = 0;lang[i] != 0;i++)
goto not_equal;
if (nargs == 0) {
int qualified);
c = *cur;
goto encoding_error;
goto encoding_error;
goto encoding_error;
return(val);
return((int) *cur);
*len = 0;
xmlChar *
in++;
in++;
if (count == 0)
return(NULL);
return(ret);
static xmlChar *
NEXT;
return(ret);
xmlChar *
in++;
in++;
return(ret);
static xmlChar *
c = CUR_CHAR(l);
return(NULL);
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
NEXTL(l);
c = CUR_CHAR(l);
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
NEXTL(l);
c = CUR_CHAR(l);
return(buffer);
if (len == 0)
return(NULL);
#ifdef __GNUC__
return(xmlXPathNAN);
cur++;
#ifdef __GNUC__
ret = 0;
cur++;
ret = 0;
cur++;
cur++;
return(xmlXPathNAN);
cur++;
cur++;
cur++;
cur++;
cur++;
cur++;
return(ret);
#ifdef __GNUC__
#ifdef __GNUC__
ret = 0;
NEXT;
ret = 0;
NEXT;
NEXT;
NEXT;
NEXT;
NEXT;
NEXT;
NEXT;
if (is_exponent_negative)
static xmlChar *
const xmlChar *q;
NEXT;
q = CUR_PTR;
NEXT;
NEXT;
NEXT;
q = CUR_PTR;
NEXT;
NEXT;
return(ret);
const xmlChar *q;
NEXT;
q = CUR_PTR;
NEXT;
NEXT;
NEXT;
q = CUR_PTR;
NEXT;
NEXT;
NEXT;
#ifdef DEBUG_EXPR
name);
NEXT;
sort = 0;
while (CUR != 0) {
nbargs++;
NEXT;
NEXT;
NEXT;
NEXT;
static xmlChar *
c = CUR_CHAR(l);
return(NULL);
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
len += l;
NEXTL(l);
c = CUR_CHAR(l);
return(ret);
lc = 0;
#ifdef DEBUG_STEP
#ifdef DEBUG_STEP
#ifdef DEBUG_STEP
#ifdef DEBUG_STEP
#ifdef DEBUG_STEP
lc = 0;
#ifdef DEBUG_STEP
len++;
#ifdef DEBUG_STEP
if (lc) {
NEXT;
NEXT;
if (found) {
if (minus)
op = 0;
NEXT;
else plus = 0;
NEXT;
else inf = 0;
NEXT;
else eq = 0;
NEXT;
NEXT;
if (! filter)
if (filter)
NEXT;
static xmlChar *
return(NULL);
NEXT;
return(NULL);
NEXT;
NEXT;
return(name);
NEXT;
NEXT;
return(NULL);
return(name);
static xmlXPathAxisVal
switch (name[0]) {
return(ret);
#ifdef LIBXML_XPTR_ENABLED
NEXT;
#ifdef LIBXML_XPTR_ENABLED
NEXT;
NEXT;
goto eval_predicates;
if (axis != 0) {
NEXT;
if (test == 0)
#ifdef DEBUG_STEP
#ifdef DEBUG_STEP
#ifdef LIBXML_XPTR_ENABLED
#ifdef LIBXML_XPTR_ENABLED
if (rangeto) {
#ifdef DEBUG_STEP
NEXT;
NEXT;
* short for div/descendant-or-self::node()/child::para and so will
NEXT;
if ((CUR != 0 ) &&
#ifdef DEBUG_STEP
int nbNodes)
switch (axis) {
case AXIS_ANCESTOR:
case AXIS_ANCESTOR_OR_SELF:
case AXIS_ATTRIBUTE:
case AXIS_CHILD:
case AXIS_DESCENDANT:
case AXIS_DESCENDANT_OR_SELF:
case AXIS_FOLLOWING:
case AXIS_FOLLOWING_SIBLING:
case AXIS_NAMESPACE:
case AXIS_PARENT:
case AXIS_PRECEDING:
case AXIS_PRECEDING_SIBLING:
case AXIS_SELF:
switch (test) {
case NODE_TEST_NONE:
case NODE_TEST_TYPE:
case NODE_TEST_PI:
case NODE_TEST_ALL:
case NODE_TEST_NS:
prefix);
case NODE_TEST_NAME:
int contextSize,
int hasNsNodes)
if (contextSize <= 0)
#ifdef LIBXML_XPTR_ENABLED
newContextSize = 0;
newContextSize = 0;
goto evaluation_exit;
if (res != 0) {
* Reset/invalidate the context.
return(newContextSize);
return(contextSize);
int contextSize,
int minPos,
int maxPos,
int hasNsNodes)
if (contextSize <= 0)
return (contextSize);
#ifdef LIBXML_XPTR_ENABLED
goto evaluation_error;
if (res)
pos++;
goto evaluation_exit;
goto evaluation_exit;
goto evaluation_exit;
newContextSize = 0;
* Reset/invalidate the context.
return(newContextSize);
return(contextSize);
int *maxPos)
(float) *maxPos)
int toBool)
if (hasAxisRange != 0) { \
goto axis_range_end; } \
if (hasAxisRange != 0) { \
goto axis_range_end; } \
#ifdef DEBUG_STEP
switch (axis) {
case AXIS_ANCESTOR:
case AXIS_ANCESTOR_OR_SELF:
case AXIS_ATTRIBUTE:
case AXIS_CHILD:
case AXIS_DESCENDANT:
case AXIS_DESCENDANT_OR_SELF:
case AXIS_FOLLOWING:
case AXIS_FOLLOWING_SIBLING:
case AXIS_NAMESPACE:
case AXIS_PARENT:
case AXIS_PRECEDING:
case AXIS_PRECEDING_SIBLING:
case AXIS_SELF:
#ifdef DEBUG_STEP
maxPos = 0;
hasPredicateRange = 0;
hasAxisRange = 0;
contextIdx = 0;
total = 0;
goto error;
pos = 0;
hasNsNodes = 0;
total++;
#ifdef DEBUG_STEP
switch (test) {
case NODE_TEST_NONE:
total = 0;
goto error;
case NODE_TEST_TYPE:
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
case XML_NAMESPACE_DECL:
case NODE_TEST_PI:
case NODE_TEST_ALL:
case NODE_TEST_NS:{
TODO;
case NODE_TEST_NAME:
case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:{
case XML_NAMESPACE_DECL:
goto apply_predicates;
if (toBool)
#ifdef DEBUG_STEP
if (hasPredicateRange != 0)
total = 0;
goto error;
if (newSize == 0) {
if (toBool)
#ifdef DEBUG_STEP
return(total);
case XPATH_OP_END:
case XPATH_OP_UNION:
total =
first);
cur =
first);
case XPATH_OP_ROOT:
case XPATH_OP_NODE:
return (total);
case XPATH_OP_RESET:
return (total);
case XPATH_OP_COLLECT:{
return (total);
return (total);
case XPATH_OP_VALUE:
case XPATH_OP_SORT:
total +=
first);
return (total);
#ifdef XP_OPTIMIZED_FILTER_FIRST
case XPATH_OP_FILTER:
return (total);
case XPATH_OP_END:
case XPATH_OP_UNION:
total =
*last =
cur =
case XPATH_OP_ROOT:
case XPATH_OP_NODE:
return (total);
case XPATH_OP_RESET:
return (total);
case XPATH_OP_COLLECT:{
return (total);
case XPATH_OP_VALUE:
case XPATH_OP_SORT:
total +=
last);
return (total);
#ifdef XP_OPTIMIZED_FILTER_FIRST
total +=
&last);
value->
nodeNr -
return (total);
return (total);
return (total);
#ifdef LIBXML_XPTR_ENABLED
return (total);
return (total);
return(total);
case XPATH_OP_END:
case XPATH_OP_AND:
return (total);
return (total);
case XPATH_OP_OR:
return (total);
return (total);
case XPATH_OP_EQUAL:
return (total);
case XPATH_OP_CMP:
return (total);
case XPATH_OP_PLUS:
return (total);
case XPATH_OP_MULT:
return (total);
case XPATH_OP_UNION:
return (total);
case XPATH_OP_ROOT:
return (total);
case XPATH_OP_NODE:
return (total);
case XPATH_OP_RESET:
return (total);
case XPATH_OP_COLLECT:{
return (total);
return (total);
case XPATH_OP_VALUE:
return (total);
case XPATH_OP_VARIABLE:{
total +=
return (total);
return (total);
case XPATH_OP_FUNCTION:{
total +=
return (total);
return (total);
func =
return (total);
return (total);
case XPATH_OP_ARG:
return (total);
case XPATH_OP_PREDICATE:
case XPATH_OP_FILTER:{
#ifdef XP_OPTIMIZED_FILTER_FIRST
total +=
&first);
return (total);
total +=
&last);
value->
nodeNr -
return (total);
total +=
return (total);
return (total);
#ifdef LIBXML_XPTR_ENABLED
total +=
return (total);
total +=
return (total);
total +=
return (total);
case XPATH_OP_SORT:
return (total);
#ifdef LIBXML_XPTR_ENABLED
case XPATH_OP_RANGETO:{
total +=
return (total);
return (total);
total +=
total +=
range =
res);
return (total);
return (total);
int isPredicate)
case XPATH_OP_END:
case XPATH_OP_VALUE:
if (isPredicate)
case XPATH_OP_SORT:
goto start;
case XPATH_OP_COLLECT:
if (resObj) {
} else if (isPredicate) {
return(res);
#ifdef XPATH_STREAMING
if (from_root < 0)
if (! toBool) {
if (min_depth == 0) {
if (from_root) {
if (toBool)
if (toBool)
if (max_depth == 0) {
if (from_root) {
case XML_ELEMENT_NODE:
case XML_DOCUMENT_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
case XML_NOTATION_NODE:
case XML_DTD_NODE:
case XML_DOCUMENT_TYPE_NODE:
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
case XML_ENTITY_DECL:
case XML_NAMESPACE_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
if (from_root) {
if (ret < 0) {
if (toBool)
goto return_1;
depth = 0;
goto scan_children;
nb_nodes++;
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
case XML_PI_NODE:
} else if (eval_all_nodes)
if (ret < 0) {
if (toBool)
goto return_1;
goto next_node;
depth++;
goto next_node;
depth--;
goto done;
} else if ((eval_all_nodes) &&
done:
if (patstream)
if (patstream)
#ifdef XPATH_STREAMING
if (toBool) {
return(res);
if (toBool)
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
case XPATH_BOOLEAN:
case XPATH_NUMBER:
case XPATH_NODESET:
case XPATH_XSLT_TREE:
case XPATH_STRING:
#ifdef LIBXML_XPTR_ENABLED
case XPATH_LOCATIONSET:{
#ifdef XPATH_STREAMING
static xmlXPathCompExprPtr
return(NULL);
return(NULL);
&namespaces[0]);
return(NULL);
return(comp);
return(NULL);
} while (*expr++);
#ifdef XPATH_STREAMING
return(comp);
xmlXPathInit();
return NULL;
return(NULL);
#ifdef DEBUG_EVAL_COUNTS
return(comp);
int toBool)
#ifndef LIBXML_THREAD_ENABLED
xmlXPathInit();
#ifndef LIBXML_THREAD_ENABLED
reentance++;
#ifdef DEBUG_EVAL_COUNTS
if (resObj) {
stack++;
if ((stack != 0) &&
stack);
#ifndef LIBXML_THREAD_ENABLED
reentance--;
return(res);
return(res);
#ifdef XPATH_STREAMING
#ifdef XPATH_STREAMING
xmlXPathInit();
return NULL;
#ifdef XPATH_STREAMING
stack++;
stack);
return(res);
xmlXPathInit();
return NULL;
stack++;
stack);
return(res);
* xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), true())
* returns "gopher%3A%2F%2Fspinaltap.micro.umn.edu%2F00%2FWeather%2FCalifornia%2FLos%20Angeles%23ocean"
* xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), false())
* returns "gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles%23ocean"
if (target) {
(!escape_reserved &&
#include "elfgcchack.h"