Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * xpath.c: internal interfaces for XML Path Language implementation |
| 3 | * used to build new modules on top of XPath |
| 4 | * |
| 5 | * See COPYRIGHT for the status of this software |
| 6 | * |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 7 | * Author: daniel@veillard.com |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __XML_XPATH_INTERNALS_H__ |
| 11 | #define __XML_XPATH_INTERNALS_H__ |
| 12 | |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 13 | #if defined(WIN32) && defined(_MSC_VER) |
| 14 | #include <libxml/xmlwin32version.h> |
| 15 | #else |
Daniel Veillard | 017b108 | 2001-06-21 11:20:21 +0000 | [diff] [blame] | 16 | #include <libxml/xmlversion.h> |
Daniel Veillard | c5d6434 | 2001-06-24 12:13:24 +0000 | [diff] [blame] | 17 | #endif |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 18 | #include <libxml/xpath.h> |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | /************************************************************************ |
| 25 | * * |
| 26 | * Helpers * |
| 27 | * * |
| 28 | ************************************************************************/ |
| 29 | |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 30 | /** |
| 31 | * Many of these macros may later turn into functions. They |
| 32 | * shouldn't be used in #ifdef's preprocessor instructions. |
| 33 | */ |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 34 | /** |
| 35 | * xmlXPathSetError: |
| 36 | * @ctxt: an XPath parser context |
| 37 | * @err: an xmlXPathError code |
| 38 | * |
| 39 | * Raises an error. |
| 40 | */ |
| 41 | #define xmlXPathSetError(ctxt, err) \ |
| 42 | { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \ |
| 43 | (ctxt)->error = (err); } |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 44 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 45 | /** |
| 46 | * xmlXPathSetArityError: |
| 47 | * @ctxt: an XPath parser context |
| 48 | * |
| 49 | * Raises an XPATH_INVALID_ARITY error |
| 50 | */ |
| 51 | #define xmlXPathSetArityError(ctxt) \ |
| 52 | xmlXPathSetError((ctxt), XPATH_INVALID_ARITY) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 53 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 54 | /** |
| 55 | * xmlXPathSetTypeError: |
| 56 | * @ctxt: an XPath parser context |
| 57 | * |
| 58 | * Raises an XPATH_INVALID_TYPE error |
| 59 | */ |
| 60 | #define xmlXPathSetTypeError(ctxt) \ |
| 61 | xmlXPathSetError((ctxt), XPATH_INVALID_TYPE) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 62 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 63 | /** |
| 64 | * xmlXPathGetError: |
| 65 | * @ctxt: an XPath parser context |
| 66 | * |
| 67 | * Returns the context error |
| 68 | */ |
| 69 | #define xmlXPathGetError(ctxt) ((ctxt)->error) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 70 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 71 | /** |
| 72 | * xmlXPathCheckError: |
| 73 | * @ctxt: an XPath parser context |
| 74 | * |
| 75 | * Returns true if an error has been raised, false otherwise. |
| 76 | */ |
| 77 | #define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK) |
| 78 | |
| 79 | /** |
| 80 | * xmlXPathGetDocument: |
| 81 | * @ctxt: an XPath parser context |
| 82 | * |
| 83 | * Returns the context document |
| 84 | */ |
| 85 | #define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 86 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 87 | /** |
| 88 | * xmlXPathGetContextNode: |
| 89 | * @ctxt: an XPath parser context |
| 90 | * |
| 91 | * Returns the context node |
| 92 | */ |
| 93 | #define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node) |
| 94 | |
| 95 | int xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt); |
| 96 | double xmlXPathPopNumber (xmlXPathParserContextPtr ctxt); |
| 97 | xmlChar * xmlXPathPopString (xmlXPathParserContextPtr ctxt); |
| 98 | xmlNodeSetPtr xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt); |
| 99 | void * xmlXPathPopExternal (xmlXPathParserContextPtr ctxt); |
| 100 | |
| 101 | /** |
| 102 | * xmlXPathReturnBoolean: |
| 103 | * @ctxt: an XPath parser context |
| 104 | * @val: a boolean |
| 105 | * |
| 106 | * Pushes the boolean @val on the context stack |
| 107 | */ |
| 108 | #define xmlXPathReturnBoolean(ctxt, val) \ |
| 109 | valuePush((ctxt), xmlXPathNewBoolean(val)) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 110 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 111 | /** |
| 112 | * xmlXPathReturnTrue: |
| 113 | * @ctxt: an XPath parser context |
| 114 | * |
| 115 | * Pushes true on the context stack |
| 116 | */ |
| 117 | #define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 118 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 119 | /** |
| 120 | * xmlXPathReturnFalse: |
| 121 | * @ctxt: an XPath parser context |
| 122 | * |
| 123 | * Pushes false on the context stack |
| 124 | */ |
| 125 | #define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 126 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 127 | /** |
| 128 | * xmlXPathReturnNumber: |
| 129 | * @ctxt: an XPath parser context |
| 130 | * @val: a double |
| 131 | * |
| 132 | * Pushes the double @val on the context stack |
| 133 | */ |
| 134 | #define xmlXPathReturnNumber(ctxt, val) \ |
| 135 | valuePush((ctxt), xmlXPathNewFloat(val)) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 136 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 137 | /** |
| 138 | * xmlXPathReturnString: |
| 139 | * @ctxt: an XPath parser context |
| 140 | * @str: a string |
| 141 | * |
| 142 | * Pushes the string @str on the context stack |
| 143 | */ |
| 144 | #define xmlXPathReturnString(ctxt, str) \ |
| 145 | valuePush((ctxt), xmlXPathWrapString(str)) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 146 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 147 | /** |
| 148 | * xmlXPathReturnEmptyString: |
| 149 | * @ctxt: an XPath parser context |
| 150 | * |
| 151 | * Pushes an empty string on the stack |
| 152 | */ |
| 153 | #define xmlXPathReturnEmptyString(ctxt) \ |
| 154 | valuePush((ctxt), xmlXPathNewCString("")) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 155 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 156 | /** |
| 157 | * xmlXPathReturnNodeSet: |
| 158 | * @ctxt: an XPath parser context |
| 159 | * @ns: a node-set |
| 160 | * |
| 161 | * Pushes the node-set @ns on the context stack |
| 162 | */ |
| 163 | #define xmlXPathReturnNodeSet(ctxt, ns) \ |
| 164 | valuePush((ctxt), xmlXPathWrapNodeSet(ns)) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 165 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 166 | /** |
| 167 | * xmlXPathReturnEmptyNodeSet: |
| 168 | * @ctxt: an XPath parser context |
| 169 | * |
| 170 | * Pushes an empty node-set on the context stack |
| 171 | */ |
| 172 | #define xmlXPathReturnEmptyNodeSet(ctxt, ns) \ |
| 173 | valuePush((ctxt), xmlXPathNewNodeSet(NULL)) |
Daniel Veillard | 8fcc494 | 2001-07-17 20:07:33 +0000 | [diff] [blame] | 174 | |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 175 | /** |
| 176 | * xmlXPathReturnExternal: |
| 177 | * @ctxt: an XPath parser context |
| 178 | * @val: user data |
| 179 | * |
| 180 | * Pushes user data on the context stack |
| 181 | */ |
| 182 | #define xmlXPathReturnExternal(ctxt, val) \ |
| 183 | valuePush((ctxt), xmlXPathWrapExternal(val)) |
| 184 | |
| 185 | /** |
| 186 | * xmlXPathStackIsNodeSet: |
| 187 | * @ctxt: an XPath parser context |
| 188 | * |
| 189 | * Returns true if the current object on the stack is a node-set |
| 190 | */ |
| 191 | #define xmlXPathStackIsNodeSet(ctxt) \ |
| 192 | (((ctxt)->value != NULL) \ |
| 193 | && (((ctxt)->value->type == XPATH_NODESET) \ |
| 194 | || ((ctxt)->value->type == XPATH_XSLT_TREE))) |
| 195 | |
| 196 | /** |
| 197 | * xmlXPathEmptyNodeSet: |
| 198 | * @ns: a node-set |
| 199 | * |
| 200 | * Empties a node-set |
| 201 | */ |
| 202 | #define xmlXPathEmptyNodeSet(ns) \ |
| 203 | { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; } |
| 204 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 205 | /** |
| 206 | * CHECK_ERROR: |
| 207 | * |
| 208 | * macro to return from the function if an XPath error was detected |
| 209 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 210 | #define CHECK_ERROR \ |
| 211 | if (ctxt->error != XPATH_EXPRESSION_OK) return |
| 212 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 213 | /** |
| 214 | * CHECK_ERROR0: |
| 215 | * |
| 216 | * macro to return 0 from the function if an XPath error was detected |
| 217 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 218 | #define CHECK_ERROR0 \ |
| 219 | if (ctxt->error != XPATH_EXPRESSION_OK) return(0) |
| 220 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 221 | /** |
| 222 | * XP_ERROR: |
| 223 | * @X: the error code |
| 224 | * |
| 225 | * Macro to raise an XPath error and return |
| 226 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 227 | #define XP_ERROR(X) \ |
| 228 | { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \ |
| 229 | ctxt->error = (X); return; } |
| 230 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 231 | /** |
| 232 | * XP_ERROR0: |
| 233 | * @X: the error code |
| 234 | * |
| 235 | * Macro to raise an XPath error and return 0 |
| 236 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 237 | #define XP_ERROR0(X) \ |
| 238 | { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \ |
| 239 | ctxt->error = (X); return(0); } |
| 240 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 241 | /** |
| 242 | * CHECK_TYPE: |
| 243 | * @typeval: the XPath type |
| 244 | * |
| 245 | * Macro to check that the value on top of the XPath stack is of a given |
| 246 | * type. |
| 247 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 248 | #define CHECK_TYPE(typeval) \ |
| 249 | if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ |
| 250 | XP_ERROR(XPATH_INVALID_TYPE) |
| 251 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 252 | /** |
Daniel Veillard | f06307e | 2001-07-03 10:35:50 +0000 | [diff] [blame] | 253 | * CHECK_TYPE0: |
| 254 | * @typeval: the XPath type |
| 255 | * |
| 256 | * Macro to check that the value on top of the XPath stack is of a given |
| 257 | * type. return(0) in case of failure |
| 258 | */ |
| 259 | #define CHECK_TYPE0(typeval) \ |
| 260 | if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \ |
| 261 | XP_ERROR0(XPATH_INVALID_TYPE) |
| 262 | |
| 263 | /** |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 264 | * CHECK_ARITY: |
| 265 | * @x: the number of expected args |
| 266 | * |
| 267 | * Macro to check that the number of args passed to an XPath function matches |
| 268 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 269 | #define CHECK_ARITY(x) \ |
| 270 | if (nargs != (x)) \ |
| 271 | XP_ERROR(XPATH_INVALID_ARITY); |
| 272 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 273 | /** |
| 274 | * CAST_TO_STRING: |
| 275 | * |
| 276 | * Macro to try to cast the value on the top of the XPath stack to a string |
| 277 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 278 | #define CAST_TO_STRING \ |
| 279 | if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \ |
| 280 | xmlXPathStringFunction(ctxt, 1); |
| 281 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 282 | /** |
| 283 | * CAST_TO_NUMBER: |
| 284 | * |
| 285 | * Macro to try to cast the value on the top of the XPath stack to a number |
| 286 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 287 | #define CAST_TO_NUMBER \ |
| 288 | if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \ |
| 289 | xmlXPathNumberFunction(ctxt, 1); |
| 290 | |
Daniel Veillard | bed7b05 | 2001-05-19 14:59:49 +0000 | [diff] [blame] | 291 | /** |
| 292 | * CAST_TO_BOOLEAN: |
| 293 | * |
| 294 | * Macro to try to cast the value on the top of the XPath stack to a boolean |
| 295 | */ |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 296 | #define CAST_TO_BOOLEAN \ |
| 297 | if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \ |
| 298 | xmlXPathBooleanFunction(ctxt, 1); |
| 299 | |
| 300 | /* |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 301 | * Variable Lookup forwarding |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 302 | */ |
| 303 | typedef xmlXPathObjectPtr |
| 304 | (*xmlXPathVariableLookupFunc) (void *ctxt, |
| 305 | const xmlChar *name, |
| 306 | const xmlChar *ns_uri); |
| 307 | |
| 308 | void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt, |
| 309 | xmlXPathVariableLookupFunc f, |
| 310 | void *varCtxt); |
| 311 | |
| 312 | /* |
| 313 | * Error reporting |
| 314 | */ |
| 315 | void xmlXPatherror (xmlXPathParserContextPtr ctxt, |
| 316 | const char *file, |
| 317 | int line, |
| 318 | int no); |
| 319 | |
| 320 | void xmlXPathDebugDumpObject (FILE *output, |
| 321 | xmlXPathObjectPtr cur, |
| 322 | int depth); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 323 | void xmlXPathDebugDumpCompExpr(FILE *output, |
| 324 | xmlXPathCompExprPtr comp, |
| 325 | int depth); |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 326 | |
| 327 | /** |
| 328 | * NodeSet handling |
| 329 | */ |
| 330 | xmlNodeSetPtr xmlXPathDifference (xmlNodeSetPtr nodes1, |
| 331 | xmlNodeSetPtr nodes2); |
| 332 | xmlNodeSetPtr xmlXPathIntersection (xmlNodeSetPtr nodes1, |
| 333 | xmlNodeSetPtr nodes2); |
| 334 | |
| 335 | xmlNodeSetPtr xmlXPathDistinctSorted (xmlNodeSetPtr nodes); |
| 336 | xmlNodeSetPtr xmlXPathDistinct (xmlNodeSetPtr nodes); |
| 337 | |
| 338 | int xmlXPathHasSameNodes (xmlNodeSetPtr nodes1, |
| 339 | xmlNodeSetPtr nodes2); |
| 340 | |
| 341 | xmlNodeSetPtr xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, |
| 342 | xmlNodePtr node); |
| 343 | xmlNodeSetPtr xmlXPathLeadingSorted (xmlNodeSetPtr nodes1, |
| 344 | xmlNodeSetPtr nodes2); |
| 345 | xmlNodeSetPtr xmlXPathNodeLeading (xmlNodeSetPtr nodes, |
| 346 | xmlNodePtr node); |
| 347 | xmlNodeSetPtr xmlXPathLeading (xmlNodeSetPtr nodes1, |
| 348 | xmlNodeSetPtr nodes2); |
| 349 | |
| 350 | xmlNodeSetPtr xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, |
| 351 | xmlNodePtr node); |
| 352 | xmlNodeSetPtr xmlXPathTrailingSorted (xmlNodeSetPtr nodes1, |
| 353 | xmlNodeSetPtr nodes2); |
| 354 | xmlNodeSetPtr xmlXPathNodeTrailing (xmlNodeSetPtr nodes, |
| 355 | xmlNodePtr node); |
| 356 | xmlNodeSetPtr xmlXPathTrailing (xmlNodeSetPtr nodes1, |
| 357 | xmlNodeSetPtr nodes2); |
| 358 | |
| 359 | |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 360 | /** |
| 361 | * Extending a context |
| 362 | */ |
| 363 | |
| 364 | int xmlXPathRegisterNs (xmlXPathContextPtr ctxt, |
| 365 | const xmlChar *prefix, |
| 366 | const xmlChar *ns_uri); |
| 367 | const xmlChar * xmlXPathNsLookup (xmlXPathContextPtr ctxt, |
| 368 | const xmlChar *ns_uri); |
| 369 | void xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt); |
| 370 | |
| 371 | int xmlXPathRegisterFunc (xmlXPathContextPtr ctxt, |
| 372 | const xmlChar *name, |
| 373 | xmlXPathFunction f); |
| 374 | int xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt, |
| 375 | const xmlChar *name, |
| 376 | const xmlChar *ns_uri, |
| 377 | xmlXPathFunction f); |
| 378 | int xmlXPathRegisterVariable (xmlXPathContextPtr ctxt, |
| 379 | const xmlChar *name, |
| 380 | xmlXPathObjectPtr value); |
| 381 | int xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt, |
| 382 | const xmlChar *name, |
| 383 | const xmlChar *ns_uri, |
| 384 | xmlXPathObjectPtr value); |
| 385 | xmlXPathFunction xmlXPathFunctionLookup (xmlXPathContextPtr ctxt, |
| 386 | const xmlChar *name); |
| 387 | xmlXPathFunction xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt, |
| 388 | const xmlChar *name, |
| 389 | const xmlChar *ns_uri); |
| 390 | void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt); |
| 391 | xmlXPathObjectPtr xmlXPathVariableLookup (xmlXPathContextPtr ctxt, |
| 392 | const xmlChar *name); |
| 393 | xmlXPathObjectPtr xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt, |
| 394 | const xmlChar *name, |
| 395 | const xmlChar *ns_uri); |
| 396 | void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt); |
| 397 | |
| 398 | /** |
| 399 | * Utilities to extend XPath |
| 400 | */ |
| 401 | xmlXPathParserContextPtr |
| 402 | xmlXPathNewParserContext (const xmlChar *str, |
| 403 | xmlXPathContextPtr ctxt); |
| 404 | void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt); |
| 405 | |
| 406 | /* TODO: remap to xmlXPathValuePop and Push */ |
| 407 | xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt); |
| 408 | int valuePush (xmlXPathParserContextPtr ctxt, |
| 409 | xmlXPathObjectPtr value); |
| 410 | |
| 411 | xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val); |
| 412 | xmlXPathObjectPtr xmlXPathNewCString (const char *val); |
Daniel Veillard | ba0b8c9 | 2001-05-15 09:43:47 +0000 | [diff] [blame] | 413 | xmlXPathObjectPtr xmlXPathWrapString (xmlChar *val); |
| 414 | xmlXPathObjectPtr xmlXPathWrapCString (char *val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 415 | xmlXPathObjectPtr xmlXPathNewFloat (double val); |
| 416 | xmlXPathObjectPtr xmlXPathNewBoolean (int val); |
| 417 | xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val); |
| 418 | xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val); |
| 419 | void xmlXPathNodeSetAdd (xmlNodeSetPtr cur, |
| 420 | xmlNodePtr val); |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 421 | void xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur, |
| 422 | xmlNodePtr val); |
| 423 | void xmlXPathNodeSetSort (xmlNodeSetPtr set); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 424 | |
| 425 | void xmlXPathIdFunction (xmlXPathParserContextPtr ctxt, |
| 426 | int nargs); |
| 427 | void xmlXPathRoot (xmlXPathParserContextPtr ctxt); |
| 428 | void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt); |
| 429 | xmlChar * xmlXPathParseName (xmlXPathParserContextPtr ctxt); |
| 430 | xmlChar * xmlXPathParseNCName (xmlXPathParserContextPtr ctxt); |
| 431 | |
| 432 | /* |
| 433 | * Debug |
| 434 | */ |
| 435 | #ifdef LIBXML_DEBUG_ENABLED |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 436 | void xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth); |
| 437 | #endif |
| 438 | /* |
| 439 | * Existing functions |
| 440 | */ |
Daniel Veillard | 017b108 | 2001-06-21 11:20:21 +0000 | [diff] [blame] | 441 | double xmlXPathStringEvalNumber(const xmlChar *str); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 442 | int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt, |
| 443 | xmlXPathObjectPtr res); |
| 444 | void xmlXPathInit(void); |
| 445 | void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 446 | void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt); |
| 447 | xmlNodeSetPtr xmlXPathNodeSetCreate(xmlNodePtr val); |
| 448 | void xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val); |
| 449 | xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2); |
| 450 | void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val); |
| 451 | void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val); |
| 452 | void xmlXPathFreeNodeSet(xmlNodeSetPtr obj); |
| 453 | xmlXPathObjectPtr xmlXPathNewNodeSet(xmlNodePtr val); |
| 454 | xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val); |
| 455 | xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val); |
Thomas Broyer | f06a3d8 | 2001-07-16 04:52:57 +0000 | [diff] [blame] | 456 | xmlXPathObjectPtr xmlXPathWrapExternal(void *val); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 457 | void xmlXPathFreeNodeSetList(xmlXPathObjectPtr obj); |
| 458 | |
| 459 | |
| 460 | xmlXPathObjectPtr xmlXPathNewFloat(double val); |
| 461 | xmlXPathObjectPtr xmlXPathNewBoolean(int val); |
| 462 | xmlXPathObjectPtr xmlXPathNewString(const xmlChar *val); |
| 463 | xmlXPathObjectPtr xmlXPathNewCString(const char *val); |
| 464 | void xmlXPathFreeObject(xmlXPathObjectPtr obj); |
| 465 | xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc); |
| 466 | void xmlXPathFreeContext(xmlXPathContextPtr ctxt); |
| 467 | |
| 468 | int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt); |
| 469 | int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict); |
| 470 | void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt); |
| 471 | void xmlXPathAddValues(xmlXPathParserContextPtr ctxt); |
| 472 | void xmlXPathSubValues(xmlXPathParserContextPtr ctxt); |
| 473 | void xmlXPathMultValues(xmlXPathParserContextPtr ctxt); |
| 474 | void xmlXPathDivValues(xmlXPathParserContextPtr ctxt); |
| 475 | void xmlXPathModValues(xmlXPathParserContextPtr ctxt); |
| 476 | |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 477 | int xmlXPathIsNodeType(const xmlChar *name); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 478 | |
| 479 | /* |
| 480 | * Some of the axis navigation routines |
| 481 | */ |
Daniel Veillard | 56a4cb8 | 2001-03-24 17:00:36 +0000 | [diff] [blame] | 482 | xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, |
| 483 | xmlNodePtr cur); |
| 484 | xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt, |
| 485 | xmlNodePtr cur); |
| 486 | xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, |
| 487 | xmlNodePtr cur); |
| 488 | xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, |
| 489 | xmlNodePtr cur); |
| 490 | xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt, |
| 491 | xmlNodePtr cur); |
| 492 | xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, |
| 493 | xmlNodePtr cur); |
| 494 | xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, |
| 495 | xmlNodePtr cur); |
| 496 | xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, |
| 497 | xmlNodePtr cur); |
| 498 | xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, |
| 499 | xmlNodePtr cur); |
| 500 | xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, |
| 501 | xmlNodePtr cur); |
| 502 | xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, |
| 503 | xmlNodePtr cur); |
| 504 | xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, |
| 505 | xmlNodePtr cur); |
| 506 | xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, |
| 507 | xmlNodePtr cur); |
Owen Taylor | 3473f88 | 2001-02-23 17:55:21 +0000 | [diff] [blame] | 508 | /* |
| 509 | * The official core of XPath functions |
| 510 | */ |
| 511 | void xmlXPathRoot(xmlXPathParserContextPtr ctxt); |
| 512 | void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 513 | void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 514 | void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 515 | void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 516 | void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 517 | void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 518 | void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 519 | void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 520 | void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 521 | void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 522 | void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 523 | void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 524 | void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 525 | void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 526 | void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 527 | void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 528 | void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 529 | void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 530 | void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 531 | void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 532 | void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 533 | void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 534 | void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 535 | void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 536 | void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 537 | void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs); |
| 538 | #ifdef __cplusplus |
| 539 | } |
| 540 | #endif |
| 541 | #endif /* ! __XML_XPATH_INTERNALS_H__ */ |