blob: ae36638aac52e1b869a0c3b218893651e79d147f [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 Veillard017b1082001-06-21 11:20:21 +000013#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000014#include <libxml/xpath.h>
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20/************************************************************************
21 * *
22 * Helpers *
23 * *
24 ************************************************************************/
25
Daniel Veillard8fcc4942001-07-17 20:07:33 +000026/**
27 * Many of these macros may later turn into functions. They
28 * shouldn't be used in #ifdef's preprocessor instructions.
29 */
Thomas Broyerf06a3d82001-07-16 04:52:57 +000030/**
31 * xmlXPathSetError:
32 * @ctxt: an XPath parser context
33 * @err: an xmlXPathError code
34 *
35 * Raises an error.
36 */
37#define xmlXPathSetError(ctxt, err) \
38 { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \
39 (ctxt)->error = (err); }
Daniel Veillard8fcc4942001-07-17 20:07:33 +000040
Thomas Broyerf06a3d82001-07-16 04:52:57 +000041/**
42 * xmlXPathSetArityError:
43 * @ctxt: an XPath parser context
44 *
Daniel Veillard61f26172002-03-12 18:46:39 +000045 * Raises an XPATH_INVALID_ARITY error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000046 */
47#define xmlXPathSetArityError(ctxt) \
48 xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000049
Thomas Broyerf06a3d82001-07-16 04:52:57 +000050/**
51 * xmlXPathSetTypeError:
52 * @ctxt: an XPath parser context
53 *
Daniel Veillard61f26172002-03-12 18:46:39 +000054 * Raises an XPATH_INVALID_TYPE error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000055 */
56#define xmlXPathSetTypeError(ctxt) \
57 xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000058
Thomas Broyerf06a3d82001-07-16 04:52:57 +000059/**
60 * xmlXPathGetError:
61 * @ctxt: an XPath parser context
62 *
Daniel Veillard61f26172002-03-12 18:46:39 +000063 * Get the error code of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000064 *
Daniel Veillard61f26172002-03-12 18:46:39 +000065 * Returns the context error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000066 */
67#define xmlXPathGetError(ctxt) ((ctxt)->error)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000068
Thomas Broyerf06a3d82001-07-16 04:52:57 +000069/**
70 * xmlXPathCheckError:
71 * @ctxt: an XPath parser context
72 *
Daniel Veillard61f26172002-03-12 18:46:39 +000073 * Check if an XPath error was raised.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000074 *
Thomas Broyerf06a3d82001-07-16 04:52:57 +000075 * 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 *
Daniel Veillard61f26172002-03-12 18:46:39 +000083 * Get the document of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000084 *
Daniel Veillard61f26172002-03-12 18:46:39 +000085 * Returns the context document.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000086 */
87#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000088
Thomas Broyerf06a3d82001-07-16 04:52:57 +000089/**
90 * xmlXPathGetContextNode:
91 * @ctxt: an XPath parser context
92 *
Daniel Veillard61f26172002-03-12 18:46:39 +000093 * Get the context node of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000094 *
Daniel Veillard61f26172002-03-12 18:46:39 +000095 * Returns the context node.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000096 */
97#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node)
98
Igor Zlatkovic76874e42003-08-25 09:05:12 +000099XMLPUBFUN int XMLCALL xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
100XMLPUBFUN double XMLCALL xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
101XMLPUBFUN xmlChar * XMLCALL xmlXPathPopString (xmlXPathParserContextPtr ctxt);
102XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
103XMLPUBFUN void * XMLCALL xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000104
105/**
106 * xmlXPathReturnBoolean:
107 * @ctxt: an XPath parser context
108 * @val: a boolean
109 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000110 * Pushes the boolean @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000111 */
112#define xmlXPathReturnBoolean(ctxt, val) \
113 valuePush((ctxt), xmlXPathNewBoolean(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000114
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000115/**
116 * xmlXPathReturnTrue:
117 * @ctxt: an XPath parser context
118 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000119 * Pushes true on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000120 */
121#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000122
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000123/**
124 * xmlXPathReturnFalse:
125 * @ctxt: an XPath parser context
126 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000127 * Pushes false on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000128 */
129#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000130
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000131/**
132 * xmlXPathReturnNumber:
133 * @ctxt: an XPath parser context
134 * @val: a double
135 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000136 * Pushes the double @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000137 */
138#define xmlXPathReturnNumber(ctxt, val) \
139 valuePush((ctxt), xmlXPathNewFloat(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000140
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000141/**
142 * xmlXPathReturnString:
143 * @ctxt: an XPath parser context
144 * @str: a string
145 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000146 * Pushes the string @str on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000147 */
148#define xmlXPathReturnString(ctxt, str) \
149 valuePush((ctxt), xmlXPathWrapString(str))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000150
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000151/**
152 * xmlXPathReturnEmptyString:
153 * @ctxt: an XPath parser context
154 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000155 * Pushes an empty string on the stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000156 */
157#define xmlXPathReturnEmptyString(ctxt) \
158 valuePush((ctxt), xmlXPathNewCString(""))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000159
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000160/**
161 * xmlXPathReturnNodeSet:
162 * @ctxt: an XPath parser context
163 * @ns: a node-set
164 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000165 * Pushes the node-set @ns on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000166 */
167#define xmlXPathReturnNodeSet(ctxt, ns) \
168 valuePush((ctxt), xmlXPathWrapNodeSet(ns))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000169
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000170/**
171 * xmlXPathReturnEmptyNodeSet:
172 * @ctxt: an XPath parser context
173 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000174 * Pushes an empty node-set on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000175 */
Daniel Veillard5344c602001-12-31 16:37:34 +0000176#define xmlXPathReturnEmptyNodeSet(ctxt) \
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000177 valuePush((ctxt), xmlXPathNewNodeSet(NULL))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000178
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000179/**
180 * xmlXPathReturnExternal:
181 * @ctxt: an XPath parser context
182 * @val: user data
183 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000184 * Pushes user data on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000185 */
186#define xmlXPathReturnExternal(ctxt, val) \
187 valuePush((ctxt), xmlXPathWrapExternal(val))
188
189/**
190 * xmlXPathStackIsNodeSet:
191 * @ctxt: an XPath parser context
192 *
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000193 * Check if the current value on the XPath stack is a node set or
Daniel Veillard61f26172002-03-12 18:46:39 +0000194 * an XSLT value tree.
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000195 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000196 * Returns true if the current object on the stack is a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000197 */
198#define xmlXPathStackIsNodeSet(ctxt) \
199 (((ctxt)->value != NULL) \
200 && (((ctxt)->value->type == XPATH_NODESET) \
201 || ((ctxt)->value->type == XPATH_XSLT_TREE)))
202
203/**
Thomas Broyer47334c02001-10-07 16:41:52 +0000204 * xmlXPathStackIsExternal:
205 * @ctxt: an XPath parser context
206 *
207 * Checks if the current value on the XPath stack is an external
208 * object.
209 *
210 * Returns true if the current object on the stack is an external
Daniel Veillard61f26172002-03-12 18:46:39 +0000211 * object.
Thomas Broyer47334c02001-10-07 16:41:52 +0000212 */
213#define xmlXPathStackIsExternal(ctxt) \
214 ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))
215
216/**
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000217 * xmlXPathEmptyNodeSet:
218 * @ns: a node-set
219 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000220 * Empties a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000221 */
222#define xmlXPathEmptyNodeSet(ns) \
223 { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; }
224
Daniel Veillardbed7b052001-05-19 14:59:49 +0000225/**
226 * CHECK_ERROR:
227 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000228 * Macro to return from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000229 */
Owen Taylor3473f882001-02-23 17:55:21 +0000230#define CHECK_ERROR \
231 if (ctxt->error != XPATH_EXPRESSION_OK) return
232
Daniel Veillardbed7b052001-05-19 14:59:49 +0000233/**
234 * CHECK_ERROR0:
235 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000236 * Macro to return 0 from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000237 */
Owen Taylor3473f882001-02-23 17:55:21 +0000238#define CHECK_ERROR0 \
239 if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
240
Daniel Veillardbed7b052001-05-19 14:59:49 +0000241/**
242 * XP_ERROR:
243 * @X: the error code
244 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000245 * Macro to raise an XPath error and return.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000246 */
Owen Taylor3473f882001-02-23 17:55:21 +0000247#define XP_ERROR(X) \
248 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
249 ctxt->error = (X); return; }
250
Daniel Veillardbed7b052001-05-19 14:59:49 +0000251/**
252 * XP_ERROR0:
253 * @X: the error code
254 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000255 * Macro to raise an XPath error and return 0.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000256 */
Owen Taylor3473f882001-02-23 17:55:21 +0000257#define XP_ERROR0(X) \
258 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
259 ctxt->error = (X); return(0); }
260
Daniel Veillardbed7b052001-05-19 14:59:49 +0000261/**
262 * CHECK_TYPE:
263 * @typeval: the XPath type
264 *
265 * Macro to check that the value on top of the XPath stack is of a given
266 * type.
267 */
Owen Taylor3473f882001-02-23 17:55:21 +0000268#define CHECK_TYPE(typeval) \
269 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
270 XP_ERROR(XPATH_INVALID_TYPE)
271
Daniel Veillardbed7b052001-05-19 14:59:49 +0000272/**
Daniel Veillardf06307e2001-07-03 10:35:50 +0000273 * CHECK_TYPE0:
274 * @typeval: the XPath type
275 *
276 * Macro to check that the value on top of the XPath stack is of a given
Daniel Veillard61f26172002-03-12 18:46:39 +0000277 * type. Return(0) in case of failure
Daniel Veillardf06307e2001-07-03 10:35:50 +0000278 */
279#define CHECK_TYPE0(typeval) \
280 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
281 XP_ERROR0(XPATH_INVALID_TYPE)
282
283/**
Daniel Veillardbed7b052001-05-19 14:59:49 +0000284 * CHECK_ARITY:
285 * @x: the number of expected args
286 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000287 * Macro to check that the number of args passed to an XPath function matches.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000288 */
Owen Taylor3473f882001-02-23 17:55:21 +0000289#define CHECK_ARITY(x) \
290 if (nargs != (x)) \
291 XP_ERROR(XPATH_INVALID_ARITY);
292
Daniel Veillardbed7b052001-05-19 14:59:49 +0000293/**
294 * CAST_TO_STRING:
295 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000296 * Macro to try to cast the value on the top of the XPath stack to a string.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000297 */
Owen Taylor3473f882001-02-23 17:55:21 +0000298#define CAST_TO_STRING \
299 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
300 xmlXPathStringFunction(ctxt, 1);
301
Daniel Veillardbed7b052001-05-19 14:59:49 +0000302/**
303 * CAST_TO_NUMBER:
304 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000305 * Macro to try to cast the value on the top of the XPath stack to a number.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000306 */
Owen Taylor3473f882001-02-23 17:55:21 +0000307#define CAST_TO_NUMBER \
308 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
309 xmlXPathNumberFunction(ctxt, 1);
310
Daniel Veillardbed7b052001-05-19 14:59:49 +0000311/**
312 * CAST_TO_BOOLEAN:
313 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000314 * Macro to try to cast the value on the top of the XPath stack to a boolean.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000315 */
Owen Taylor3473f882001-02-23 17:55:21 +0000316#define CAST_TO_BOOLEAN \
317 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
318 xmlXPathBooleanFunction(ctxt, 1);
319
320/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000321 * Variable Lookup forwarding.
Owen Taylor3473f882001-02-23 17:55:21 +0000322 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000323/**
324 * xmlXPathVariableLookupFunc:
325 * @ctxt: an XPath context
326 * @name: name of the variable
327 * @ns_uri: the namespace name hosting this variable
328 *
329 * Prototype for callbacks used to plug variable lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000330 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000331 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000332 * Returns the XPath object value or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000333 */
334typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000335 const xmlChar *name,
336 const xmlChar *ns_uri);
337
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000338XMLPUBFUN void XMLCALL xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000339 xmlXPathVariableLookupFunc f,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000340 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000341
342/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000343 * Function Lookup forwarding.
Thomas Broyerba4ad322001-07-26 16:55:21 +0000344 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000345/**
346 * xmlXPathFuncLookupFunc:
347 * @ctxt: an XPath context
348 * @name: name of the function
349 * @ns_uri: the namespace name hosting this function
350 *
351 * Prototype for callbacks used to plug function lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000352 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000353 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000354 * Returns the XPath function or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000355 */
Daniel Veillard99e55eb2002-01-21 08:56:29 +0000356typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
Thomas Broyerba4ad322001-07-26 16:55:21 +0000357 const xmlChar *name,
358 const xmlChar *ns_uri);
359
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000360XMLPUBFUN void XMLCALL xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
Thomas Broyerba4ad322001-07-26 16:55:21 +0000361 xmlXPathFuncLookupFunc f,
362 void *funcCtxt);
363
364/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000365 * Error reporting.
Owen Taylor3473f882001-02-23 17:55:21 +0000366 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000367XMLPUBFUN void XMLCALL xmlXPatherror (xmlXPathParserContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000368 const char *file,
369 int line,
370 int no);
371
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000372XMLPUBFUN void XMLCALL xmlXPathDebugDumpObject (FILE *output,
Owen Taylor3473f882001-02-23 17:55:21 +0000373 xmlXPathObjectPtr cur,
374 int depth);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000375XMLPUBFUN void XMLCALL xmlXPathDebugDumpCompExpr(FILE *output,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000376 xmlXPathCompExprPtr comp,
377 int depth);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000378
379/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000380 * NodeSet handling.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000381 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000382XMLPUBFUN int XMLCALL xmlXPathNodeSetContains (xmlNodeSetPtr cur,
Thomas Broyerf186c822001-07-31 23:30:37 +0000383 xmlNodePtr val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000384XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDifference (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000385 xmlNodeSetPtr nodes2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000386XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathIntersection (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000387 xmlNodeSetPtr nodes2);
388
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000389XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
390XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathDistinct (xmlNodeSetPtr nodes);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000391
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000392XMLPUBFUN int XMLCALL xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000393 xmlNodeSetPtr nodes2);
394
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000395XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000396 xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000397XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000398 xmlNodeSetPtr nodes2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000399XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeLeading (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000400 xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000401XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathLeading (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000402 xmlNodeSetPtr nodes2);
403
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000404XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000405 xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000406XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000407 xmlNodeSetPtr nodes2);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000408XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000409 xmlNodePtr node);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000410XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathTrailing (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000411 xmlNodeSetPtr nodes2);
412
413
Owen Taylor3473f882001-02-23 17:55:21 +0000414/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000415 * Extending a context.
Owen Taylor3473f882001-02-23 17:55:21 +0000416 */
417
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000418XMLPUBFUN int XMLCALL xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000419 const xmlChar *prefix,
420 const xmlChar *ns_uri);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000421XMLPUBFUN const xmlChar * XMLCALL xmlXPathNsLookup (xmlXPathContextPtr ctxt,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000422 const xmlChar *prefix);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000423XMLPUBFUN void XMLCALL xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000424
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000425XMLPUBFUN int XMLCALL xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000426 const xmlChar *name,
427 xmlXPathFunction f);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000428XMLPUBFUN int XMLCALL xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000429 const xmlChar *name,
430 const xmlChar *ns_uri,
431 xmlXPathFunction f);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000432XMLPUBFUN int XMLCALL xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000433 const xmlChar *name,
434 xmlXPathObjectPtr value);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000435XMLPUBFUN int XMLCALL xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000436 const xmlChar *name,
437 const xmlChar *ns_uri,
438 xmlXPathObjectPtr value);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000439XMLPUBFUN xmlXPathFunction XMLCALL xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000440 const xmlChar *name);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000441XMLPUBFUN xmlXPathFunction XMLCALL xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000442 const xmlChar *name,
443 const xmlChar *ns_uri);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000444XMLPUBFUN void XMLCALL xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt);
445XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000446 const xmlChar *name);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000447XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000448 const xmlChar *name,
449 const xmlChar *ns_uri);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000450XMLPUBFUN void XMLCALL xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000451
452/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000453 * Utilities to extend XPath.
Owen Taylor3473f882001-02-23 17:55:21 +0000454 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000455XMLPUBFUN xmlXPathParserContextPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000456 xmlXPathNewParserContext (const xmlChar *str,
457 xmlXPathContextPtr ctxt);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000458XMLPUBFUN void XMLCALL xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000459
Daniel Veillard61f26172002-03-12 18:46:39 +0000460/* TODO: remap to xmlXPathValuePop and Push. */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000461XMLPUBFUN xmlXPathObjectPtr XMLCALL valuePop (xmlXPathParserContextPtr ctxt);
462XMLPUBFUN int XMLCALL valuePush (xmlXPathParserContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000463 xmlXPathObjectPtr value);
464
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000465XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewString (const xmlChar *val);
466XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewCString (const char *val);
467XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapString (xmlChar *val);
468XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapCString (char * val);
469XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewFloat (double val);
470XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewBoolean (int val);
471XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewNodeSet (xmlNodePtr val);
472XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewValueTree (xmlNodePtr val);
473XMLPUBFUN void XMLCALL xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000474 xmlNodePtr val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000475XMLPUBFUN void XMLCALL xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000476 xmlNodePtr val);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000477XMLPUBFUN void XMLCALL xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
Aleksey Sanin79376ba2002-05-14 06:41:32 +0000478 xmlNodePtr node,
479 xmlNsPtr ns);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000480XMLPUBFUN void XMLCALL xmlXPathNodeSetSort (xmlNodeSetPtr set);
Owen Taylor3473f882001-02-23 17:55:21 +0000481
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000482XMLPUBFUN void XMLCALL xmlXPathRoot (xmlXPathParserContextPtr ctxt);
483XMLPUBFUN void XMLCALL xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
484XMLPUBFUN xmlChar * XMLCALL xmlXPathParseName (xmlXPathParserContextPtr ctxt);
485XMLPUBFUN xmlChar * XMLCALL xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000486
487/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000488 * Existing functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000489 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000490XMLPUBFUN double XMLCALL xmlXPathStringEvalNumber(const xmlChar *str);
491XMLPUBFUN int XMLCALL xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000492 xmlXPathObjectPtr res);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000493XMLPUBFUN void XMLCALL xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt);
494XMLPUBFUN xmlNodeSetPtr XMLCALL xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2);
495XMLPUBFUN void XMLCALL xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val);
496XMLPUBFUN void XMLCALL xmlXPathNodeSetRemove(xmlNodeSetPtr cur, int val);
497XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathNewNodeSetList(xmlNodeSetPtr val);
498XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapNodeSet(xmlNodeSetPtr val);
499XMLPUBFUN xmlXPathObjectPtr XMLCALL xmlXPathWrapExternal(void *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000500
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000501XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
502XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
503XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
504XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
505XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
506XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
507XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
508XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
509XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000510
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000511XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name);
Owen Taylor3473f882001-02-23 17:55:21 +0000512
513/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000514 * Some of the axis navigation routines.
Owen Taylor3473f882001-02-23 17:55:21 +0000515 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000516XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000517 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000518XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000519 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000520XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000521 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000522XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000523 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000524XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000525 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000526XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000527 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000528XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000529 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000530XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000531 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000532XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000533 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000534XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000535 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000536XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000537 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000538XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000539 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000540XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000541 xmlNodePtr cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000542/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000543 * The official core of XPath functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000544 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000545XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
546XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
547XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
548XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
549XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
550XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
551XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
552XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
553XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
554XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
555XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
556XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
557XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
558XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
559XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
560XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
561XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
562XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
563XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
564XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
565XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
566XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
567XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
568XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
569XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
570XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000571
572/**
573 * Really internal functions
574 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000575XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000576
Owen Taylor3473f882001-02-23 17:55:21 +0000577#ifdef __cplusplus
578}
579#endif
580#endif /* ! __XML_XPATH_INTERNALS_H__ */