blob: 80b6b43e391e28ce720f0ae89b627f145df2b467 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillardcbaf3992001-12-31 16:16:02 +00002 * xpathInternals.c: internal interfaces for XML Path Language implementation
3 * used to build new modules on top of XPath
Owen Taylor3473f882001-02-23 17:55:21 +00004 *
5 * See COPYRIGHT for the status of this software
6 *
Daniel Veillardc5d64342001-06-24 12:13:24 +00007 * Author: daniel@veillard.com
Owen Taylor3473f882001-02-23 17:55:21 +00008 */
9
10#ifndef __XML_XPATH_INTERNALS_H__
11#define __XML_XPATH_INTERNALS_H__
12
Daniel Veillardc5d64342001-06-24 12:13:24 +000013#if defined(WIN32) && defined(_MSC_VER)
14#include <libxml/xmlwin32version.h>
15#else
Daniel Veillard017b1082001-06-21 11:20:21 +000016#include <libxml/xmlversion.h>
Daniel Veillardc5d64342001-06-24 12:13:24 +000017#endif
Owen Taylor3473f882001-02-23 17:55:21 +000018#include <libxml/xpath.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/************************************************************************
25 * *
26 * Helpers *
27 * *
28 ************************************************************************/
29
Daniel Veillard8fcc4942001-07-17 20:07:33 +000030/**
31 * Many of these macros may later turn into functions. They
32 * shouldn't be used in #ifdef's preprocessor instructions.
33 */
Thomas Broyerf06a3d82001-07-16 04:52:57 +000034/**
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 Veillard8fcc4942001-07-17 20:07:33 +000044
Thomas Broyerf06a3d82001-07-16 04:52:57 +000045/**
46 * xmlXPathSetArityError:
47 * @ctxt: an XPath parser context
48 *
Daniel Veillard61f26172002-03-12 18:46:39 +000049 * Raises an XPATH_INVALID_ARITY error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000050 */
51#define xmlXPathSetArityError(ctxt) \
52 xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000053
Thomas Broyerf06a3d82001-07-16 04:52:57 +000054/**
55 * xmlXPathSetTypeError:
56 * @ctxt: an XPath parser context
57 *
Daniel Veillard61f26172002-03-12 18:46:39 +000058 * Raises an XPATH_INVALID_TYPE error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000059 */
60#define xmlXPathSetTypeError(ctxt) \
61 xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000062
Thomas Broyerf06a3d82001-07-16 04:52:57 +000063/**
64 * xmlXPathGetError:
65 * @ctxt: an XPath parser context
66 *
Daniel Veillard61f26172002-03-12 18:46:39 +000067 * Get the error code of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000068 *
Daniel Veillard61f26172002-03-12 18:46:39 +000069 * Returns the context error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000070 */
71#define xmlXPathGetError(ctxt) ((ctxt)->error)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000072
Thomas Broyerf06a3d82001-07-16 04:52:57 +000073/**
74 * xmlXPathCheckError:
75 * @ctxt: an XPath parser context
76 *
Daniel Veillard61f26172002-03-12 18:46:39 +000077 * Check if an XPath error was raised.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000078 *
Thomas Broyerf06a3d82001-07-16 04:52:57 +000079 * Returns true if an error has been raised, false otherwise.
80 */
81#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK)
82
83/**
84 * xmlXPathGetDocument:
85 * @ctxt: an XPath parser context
86 *
Daniel Veillard61f26172002-03-12 18:46:39 +000087 * Get the document of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000088 *
Daniel Veillard61f26172002-03-12 18:46:39 +000089 * Returns the context document.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000090 */
91#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000092
Thomas Broyerf06a3d82001-07-16 04:52:57 +000093/**
94 * xmlXPathGetContextNode:
95 * @ctxt: an XPath parser context
96 *
Daniel Veillard61f26172002-03-12 18:46:39 +000097 * Get the context node of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000098 *
Daniel Veillard61f26172002-03-12 18:46:39 +000099 * Returns the context node.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000100 */
101#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node)
102
103int xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
104double xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
105xmlChar * xmlXPathPopString (xmlXPathParserContextPtr ctxt);
106xmlNodeSetPtr xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
107void * xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
108
109/**
110 * xmlXPathReturnBoolean:
111 * @ctxt: an XPath parser context
112 * @val: a boolean
113 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000114 * Pushes the boolean @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000115 */
116#define xmlXPathReturnBoolean(ctxt, val) \
117 valuePush((ctxt), xmlXPathNewBoolean(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000118
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000119/**
120 * xmlXPathReturnTrue:
121 * @ctxt: an XPath parser context
122 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000123 * Pushes true on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000124 */
125#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000126
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000127/**
128 * xmlXPathReturnFalse:
129 * @ctxt: an XPath parser context
130 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000131 * Pushes false on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000132 */
133#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000134
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000135/**
136 * xmlXPathReturnNumber:
137 * @ctxt: an XPath parser context
138 * @val: a double
139 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000140 * Pushes the double @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000141 */
142#define xmlXPathReturnNumber(ctxt, val) \
143 valuePush((ctxt), xmlXPathNewFloat(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000144
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000145/**
146 * xmlXPathReturnString:
147 * @ctxt: an XPath parser context
148 * @str: a string
149 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000150 * Pushes the string @str on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000151 */
152#define xmlXPathReturnString(ctxt, str) \
153 valuePush((ctxt), xmlXPathWrapString(str))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000154
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000155/**
156 * xmlXPathReturnEmptyString:
157 * @ctxt: an XPath parser context
158 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000159 * Pushes an empty string on the stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000160 */
161#define xmlXPathReturnEmptyString(ctxt) \
162 valuePush((ctxt), xmlXPathNewCString(""))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000163
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000164/**
165 * xmlXPathReturnNodeSet:
166 * @ctxt: an XPath parser context
167 * @ns: a node-set
168 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000169 * Pushes the node-set @ns on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000170 */
171#define xmlXPathReturnNodeSet(ctxt, ns) \
172 valuePush((ctxt), xmlXPathWrapNodeSet(ns))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000173
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000174/**
175 * xmlXPathReturnEmptyNodeSet:
176 * @ctxt: an XPath parser context
177 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000178 * Pushes an empty node-set on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000179 */
Daniel Veillard5344c602001-12-31 16:37:34 +0000180#define xmlXPathReturnEmptyNodeSet(ctxt) \
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000181 valuePush((ctxt), xmlXPathNewNodeSet(NULL))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000182
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000183/**
184 * xmlXPathReturnExternal:
185 * @ctxt: an XPath parser context
186 * @val: user data
187 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000188 * Pushes user data on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000189 */
190#define xmlXPathReturnExternal(ctxt, val) \
191 valuePush((ctxt), xmlXPathWrapExternal(val))
192
193/**
194 * xmlXPathStackIsNodeSet:
195 * @ctxt: an XPath parser context
196 *
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000197 * Check if the current value on the XPath stack is a node set or
Daniel Veillard61f26172002-03-12 18:46:39 +0000198 * an XSLT value tree.
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000199 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000200 * Returns true if the current object on the stack is a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000201 */
202#define xmlXPathStackIsNodeSet(ctxt) \
203 (((ctxt)->value != NULL) \
204 && (((ctxt)->value->type == XPATH_NODESET) \
205 || ((ctxt)->value->type == XPATH_XSLT_TREE)))
206
207/**
Thomas Broyer47334c02001-10-07 16:41:52 +0000208 * xmlXPathStackIsExternal:
209 * @ctxt: an XPath parser context
210 *
211 * Checks if the current value on the XPath stack is an external
212 * object.
213 *
214 * Returns true if the current object on the stack is an external
Daniel Veillard61f26172002-03-12 18:46:39 +0000215 * object.
Thomas Broyer47334c02001-10-07 16:41:52 +0000216 */
217#define xmlXPathStackIsExternal(ctxt) \
218 ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))
219
220/**
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000221 * xmlXPathEmptyNodeSet:
222 * @ns: a node-set
223 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000224 * Empties a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000225 */
226#define xmlXPathEmptyNodeSet(ns) \
227 { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; }
228
Daniel Veillardbed7b052001-05-19 14:59:49 +0000229/**
230 * CHECK_ERROR:
231 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000232 * Macro to return from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000233 */
Owen Taylor3473f882001-02-23 17:55:21 +0000234#define CHECK_ERROR \
235 if (ctxt->error != XPATH_EXPRESSION_OK) return
236
Daniel Veillardbed7b052001-05-19 14:59:49 +0000237/**
238 * CHECK_ERROR0:
239 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000240 * Macro to return 0 from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000241 */
Owen Taylor3473f882001-02-23 17:55:21 +0000242#define CHECK_ERROR0 \
243 if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
244
Daniel Veillardbed7b052001-05-19 14:59:49 +0000245/**
246 * XP_ERROR:
247 * @X: the error code
248 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000249 * Macro to raise an XPath error and return.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000250 */
Owen Taylor3473f882001-02-23 17:55:21 +0000251#define XP_ERROR(X) \
252 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
253 ctxt->error = (X); return; }
254
Daniel Veillardbed7b052001-05-19 14:59:49 +0000255/**
256 * XP_ERROR0:
257 * @X: the error code
258 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000259 * Macro to raise an XPath error and return 0.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000260 */
Owen Taylor3473f882001-02-23 17:55:21 +0000261#define XP_ERROR0(X) \
262 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
263 ctxt->error = (X); return(0); }
264
Daniel Veillardbed7b052001-05-19 14:59:49 +0000265/**
266 * CHECK_TYPE:
267 * @typeval: the XPath type
268 *
269 * Macro to check that the value on top of the XPath stack is of a given
270 * type.
271 */
Owen Taylor3473f882001-02-23 17:55:21 +0000272#define CHECK_TYPE(typeval) \
273 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
274 XP_ERROR(XPATH_INVALID_TYPE)
275
Daniel Veillardbed7b052001-05-19 14:59:49 +0000276/**
Daniel Veillardf06307e2001-07-03 10:35:50 +0000277 * CHECK_TYPE0:
278 * @typeval: the XPath type
279 *
280 * Macro to check that the value on top of the XPath stack is of a given
Daniel Veillard61f26172002-03-12 18:46:39 +0000281 * type. Return(0) in case of failure
Daniel Veillardf06307e2001-07-03 10:35:50 +0000282 */
283#define CHECK_TYPE0(typeval) \
284 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
285 XP_ERROR0(XPATH_INVALID_TYPE)
286
287/**
Daniel Veillardbed7b052001-05-19 14:59:49 +0000288 * CHECK_ARITY:
289 * @x: the number of expected args
290 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000291 * Macro to check that the number of args passed to an XPath function matches.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000292 */
Owen Taylor3473f882001-02-23 17:55:21 +0000293#define CHECK_ARITY(x) \
294 if (nargs != (x)) \
295 XP_ERROR(XPATH_INVALID_ARITY);
296
Daniel Veillardbed7b052001-05-19 14:59:49 +0000297/**
298 * CAST_TO_STRING:
299 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000300 * Macro to try to cast the value on the top of the XPath stack to a string.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000301 */
Owen Taylor3473f882001-02-23 17:55:21 +0000302#define CAST_TO_STRING \
303 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
304 xmlXPathStringFunction(ctxt, 1);
305
Daniel Veillardbed7b052001-05-19 14:59:49 +0000306/**
307 * CAST_TO_NUMBER:
308 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000309 * Macro to try to cast the value on the top of the XPath stack to a number.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000310 */
Owen Taylor3473f882001-02-23 17:55:21 +0000311#define CAST_TO_NUMBER \
312 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
313 xmlXPathNumberFunction(ctxt, 1);
314
Daniel Veillardbed7b052001-05-19 14:59:49 +0000315/**
316 * CAST_TO_BOOLEAN:
317 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000318 * Macro to try to cast the value on the top of the XPath stack to a boolean.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000319 */
Owen Taylor3473f882001-02-23 17:55:21 +0000320#define CAST_TO_BOOLEAN \
321 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
322 xmlXPathBooleanFunction(ctxt, 1);
323
324/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000325 * Variable Lookup forwarding.
Owen Taylor3473f882001-02-23 17:55:21 +0000326 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000327/**
328 * xmlXPathVariableLookupFunc:
329 * @ctxt: an XPath context
330 * @name: name of the variable
331 * @ns_uri: the namespace name hosting this variable
332 *
333 * Prototype for callbacks used to plug variable lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000334 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000335 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000336 * Returns the XPath object value or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000337 */
338typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000339 const xmlChar *name,
340 const xmlChar *ns_uri);
341
342void xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
343 xmlXPathVariableLookupFunc f,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000344 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000345
346/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000347 * Function Lookup forwarding.
Thomas Broyerba4ad322001-07-26 16:55:21 +0000348 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000349/**
350 * xmlXPathFuncLookupFunc:
351 * @ctxt: an XPath context
352 * @name: name of the function
353 * @ns_uri: the namespace name hosting this function
354 *
355 * Prototype for callbacks used to plug function lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000356 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000357 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000358 * Returns the XPath function or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000359 */
Daniel Veillard99e55eb2002-01-21 08:56:29 +0000360typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
Thomas Broyerba4ad322001-07-26 16:55:21 +0000361 const xmlChar *name,
362 const xmlChar *ns_uri);
363
364void xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
365 xmlXPathFuncLookupFunc f,
366 void *funcCtxt);
367
368/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000369 * Error reporting.
Owen Taylor3473f882001-02-23 17:55:21 +0000370 */
371void xmlXPatherror (xmlXPathParserContextPtr ctxt,
372 const char *file,
373 int line,
374 int no);
375
376void xmlXPathDebugDumpObject (FILE *output,
377 xmlXPathObjectPtr cur,
378 int depth);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000379void xmlXPathDebugDumpCompExpr(FILE *output,
380 xmlXPathCompExprPtr comp,
381 int depth);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000382
383/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000384 * NodeSet handling.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000385 */
Thomas Broyerf186c822001-07-31 23:30:37 +0000386int xmlXPathNodeSetContains (xmlNodeSetPtr cur,
387 xmlNodePtr val);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000388xmlNodeSetPtr xmlXPathDifference (xmlNodeSetPtr nodes1,
389 xmlNodeSetPtr nodes2);
390xmlNodeSetPtr xmlXPathIntersection (xmlNodeSetPtr nodes1,
391 xmlNodeSetPtr nodes2);
392
393xmlNodeSetPtr xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
394xmlNodeSetPtr xmlXPathDistinct (xmlNodeSetPtr nodes);
395
396int xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
397 xmlNodeSetPtr nodes2);
398
399xmlNodeSetPtr xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
400 xmlNodePtr node);
401xmlNodeSetPtr xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
402 xmlNodeSetPtr nodes2);
403xmlNodeSetPtr xmlXPathNodeLeading (xmlNodeSetPtr nodes,
404 xmlNodePtr node);
405xmlNodeSetPtr xmlXPathLeading (xmlNodeSetPtr nodes1,
406 xmlNodeSetPtr nodes2);
407
408xmlNodeSetPtr xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
409 xmlNodePtr node);
410xmlNodeSetPtr xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
411 xmlNodeSetPtr nodes2);
412xmlNodeSetPtr xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
413 xmlNodePtr node);
414xmlNodeSetPtr xmlXPathTrailing (xmlNodeSetPtr nodes1,
415 xmlNodeSetPtr nodes2);
416
417
Owen Taylor3473f882001-02-23 17:55:21 +0000418/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000419 * Extending a context.
Owen Taylor3473f882001-02-23 17:55:21 +0000420 */
421
422int xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
423 const xmlChar *prefix,
424 const xmlChar *ns_uri);
425const xmlChar * xmlXPathNsLookup (xmlXPathContextPtr ctxt,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000426 const xmlChar *prefix);
Owen Taylor3473f882001-02-23 17:55:21 +0000427void xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
428
429int xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
430 const xmlChar *name,
431 xmlXPathFunction f);
432int xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
433 const xmlChar *name,
434 const xmlChar *ns_uri,
435 xmlXPathFunction f);
436int xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
437 const xmlChar *name,
438 xmlXPathObjectPtr value);
439int xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
440 const xmlChar *name,
441 const xmlChar *ns_uri,
442 xmlXPathObjectPtr value);
443xmlXPathFunction xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
444 const xmlChar *name);
445xmlXPathFunction xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
446 const xmlChar *name,
447 const xmlChar *ns_uri);
448void xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt);
449xmlXPathObjectPtr xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
450 const xmlChar *name);
451xmlXPathObjectPtr xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
452 const xmlChar *name,
453 const xmlChar *ns_uri);
454void xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
455
456/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000457 * Utilities to extend XPath.
Owen Taylor3473f882001-02-23 17:55:21 +0000458 */
459xmlXPathParserContextPtr
460 xmlXPathNewParserContext (const xmlChar *str,
461 xmlXPathContextPtr ctxt);
462void xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
463
Daniel Veillard61f26172002-03-12 18:46:39 +0000464/* TODO: remap to xmlXPathValuePop and Push. */
Owen Taylor3473f882001-02-23 17:55:21 +0000465xmlXPathObjectPtr valuePop (xmlXPathParserContextPtr ctxt);
466int valuePush (xmlXPathParserContextPtr ctxt,
467 xmlXPathObjectPtr value);
468
469xmlXPathObjectPtr xmlXPathNewString (const xmlChar *val);
470xmlXPathObjectPtr xmlXPathNewCString (const char *val);
Daniel Veillardba0b8c92001-05-15 09:43:47 +0000471xmlXPathObjectPtr xmlXPathWrapString (xmlChar *val);
Daniel Veillard963d2ae2002-01-20 22:08:18 +0000472xmlXPathObjectPtr xmlXPathWrapCString (char * val);
Owen Taylor3473f882001-02-23 17:55:21 +0000473xmlXPathObjectPtr xmlXPathNewFloat (double val);
474xmlXPathObjectPtr xmlXPathNewBoolean (int val);
475xmlXPathObjectPtr xmlXPathNewNodeSet (xmlNodePtr val);
476xmlXPathObjectPtr xmlXPathNewValueTree (xmlNodePtr val);
477void xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
478 xmlNodePtr val);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000479void xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
480 xmlNodePtr val);
Aleksey Sanin79376ba2002-05-14 06:41:32 +0000481void xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
482 xmlNodePtr node,
483 xmlNsPtr ns);
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000484void xmlXPathNodeSetSort (xmlNodeSetPtr set);
Owen Taylor3473f882001-02-23 17:55:21 +0000485
Owen Taylor3473f882001-02-23 17:55:21 +0000486void xmlXPathRoot (xmlXPathParserContextPtr ctxt);
487void xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
488xmlChar * xmlXPathParseName (xmlXPathParserContextPtr ctxt);
489xmlChar * xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
490
491/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000492 * Existing functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000493 */
Daniel Veillard017b1082001-06-21 11:20:21 +0000494double xmlXPathStringEvalNumber(const xmlChar *str);
Owen Taylor3473f882001-02-23 17:55:21 +0000495int xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
496 xmlXPathObjectPtr res);
Owen Taylor3473f882001-02-23 17:55:21 +0000497void xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000498xmlNodeSetPtr xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2);
499void xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val);
500void xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val);
Owen Taylor3473f882001-02-23 17:55:21 +0000501xmlXPathObjectPtr xmlXPathNewNodeSetList(xmlNodeSetPtr val);
502xmlXPathObjectPtr xmlXPathWrapNodeSet(xmlNodeSetPtr val);
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000503xmlXPathObjectPtr xmlXPathWrapExternal(void *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000504
505int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
506int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
507void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
508void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
509void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
510void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
511void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
512void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
513
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000514int xmlXPathIsNodeType(const xmlChar *name);
Owen Taylor3473f882001-02-23 17:55:21 +0000515
516/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000517 * Some of the axis navigation routines.
Owen Taylor3473f882001-02-23 17:55:21 +0000518 */
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000519xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
520 xmlNodePtr cur);
521xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
522 xmlNodePtr cur);
523xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
524 xmlNodePtr cur);
525xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
526 xmlNodePtr cur);
527xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
528 xmlNodePtr cur);
529xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
530 xmlNodePtr cur);
531xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
532 xmlNodePtr cur);
533xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
534 xmlNodePtr cur);
535xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
536 xmlNodePtr cur);
537xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
538 xmlNodePtr cur);
539xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
540 xmlNodePtr cur);
541xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
542 xmlNodePtr cur);
543xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
544 xmlNodePtr cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000545/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000546 * The official core of XPath functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000547 */
Owen Taylor3473f882001-02-23 17:55:21 +0000548void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
549void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
550void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
551void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
552void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
553void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
554void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
555void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
556void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
557void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
558void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
559void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
560void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
561void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
562void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
563void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
564void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
565void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
566void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
567void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
568void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
569void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
570void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
571void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
572void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
573void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
574#ifdef __cplusplus
575}
576#endif
577#endif /* ! __XML_XPATH_INTERNALS_H__ */