blob: 6b9e996500311b19109ea75055433a36a2ccbe1d [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 Zlatkovicaa3cfbd2003-08-27 08:59:58 +000099XMLPUBFUN int XMLCALL
100 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
101XMLPUBFUN double XMLCALL
102 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
103XMLPUBFUN xmlChar * XMLCALL
104 xmlXPathPopString (xmlXPathParserContextPtr ctxt);
105XMLPUBFUN xmlNodeSetPtr XMLCALL
106 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
107XMLPUBFUN void * XMLCALL
108 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000109
110/**
111 * xmlXPathReturnBoolean:
112 * @ctxt: an XPath parser context
113 * @val: a boolean
114 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000115 * Pushes the boolean @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000116 */
117#define xmlXPathReturnBoolean(ctxt, val) \
118 valuePush((ctxt), xmlXPathNewBoolean(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000119
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000120/**
121 * xmlXPathReturnTrue:
122 * @ctxt: an XPath parser context
123 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000124 * Pushes true on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000125 */
126#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000127
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000128/**
129 * xmlXPathReturnFalse:
130 * @ctxt: an XPath parser context
131 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000132 * Pushes false on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000133 */
134#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000135
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000136/**
137 * xmlXPathReturnNumber:
138 * @ctxt: an XPath parser context
139 * @val: a double
140 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000141 * Pushes the double @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000142 */
143#define xmlXPathReturnNumber(ctxt, val) \
144 valuePush((ctxt), xmlXPathNewFloat(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000145
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000146/**
147 * xmlXPathReturnString:
148 * @ctxt: an XPath parser context
149 * @str: a string
150 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000151 * Pushes the string @str on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000152 */
153#define xmlXPathReturnString(ctxt, str) \
154 valuePush((ctxt), xmlXPathWrapString(str))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000155
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000156/**
157 * xmlXPathReturnEmptyString:
158 * @ctxt: an XPath parser context
159 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000160 * Pushes an empty string on the stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000161 */
162#define xmlXPathReturnEmptyString(ctxt) \
163 valuePush((ctxt), xmlXPathNewCString(""))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000164
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000165/**
166 * xmlXPathReturnNodeSet:
167 * @ctxt: an XPath parser context
168 * @ns: a node-set
169 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000170 * Pushes the node-set @ns on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000171 */
172#define xmlXPathReturnNodeSet(ctxt, ns) \
173 valuePush((ctxt), xmlXPathWrapNodeSet(ns))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000174
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000175/**
176 * xmlXPathReturnEmptyNodeSet:
177 * @ctxt: an XPath parser context
178 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000179 * Pushes an empty node-set on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000180 */
Daniel Veillard5344c602001-12-31 16:37:34 +0000181#define xmlXPathReturnEmptyNodeSet(ctxt) \
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000182 valuePush((ctxt), xmlXPathNewNodeSet(NULL))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000183
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000184/**
185 * xmlXPathReturnExternal:
186 * @ctxt: an XPath parser context
187 * @val: user data
188 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000189 * Pushes user data on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000190 */
191#define xmlXPathReturnExternal(ctxt, val) \
192 valuePush((ctxt), xmlXPathWrapExternal(val))
193
194/**
195 * xmlXPathStackIsNodeSet:
196 * @ctxt: an XPath parser context
197 *
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000198 * Check if the current value on the XPath stack is a node set or
Daniel Veillard61f26172002-03-12 18:46:39 +0000199 * an XSLT value tree.
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000200 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000201 * Returns true if the current object on the stack is a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000202 */
203#define xmlXPathStackIsNodeSet(ctxt) \
204 (((ctxt)->value != NULL) \
205 && (((ctxt)->value->type == XPATH_NODESET) \
206 || ((ctxt)->value->type == XPATH_XSLT_TREE)))
207
208/**
Thomas Broyer47334c02001-10-07 16:41:52 +0000209 * xmlXPathStackIsExternal:
210 * @ctxt: an XPath parser context
211 *
212 * Checks if the current value on the XPath stack is an external
213 * object.
214 *
215 * Returns true if the current object on the stack is an external
Daniel Veillard61f26172002-03-12 18:46:39 +0000216 * object.
Thomas Broyer47334c02001-10-07 16:41:52 +0000217 */
218#define xmlXPathStackIsExternal(ctxt) \
219 ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))
220
221/**
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000222 * xmlXPathEmptyNodeSet:
223 * @ns: a node-set
224 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000225 * Empties a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000226 */
227#define xmlXPathEmptyNodeSet(ns) \
228 { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; }
229
Daniel Veillardbed7b052001-05-19 14:59:49 +0000230/**
231 * CHECK_ERROR:
232 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000233 * Macro to return from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000234 */
Owen Taylor3473f882001-02-23 17:55:21 +0000235#define CHECK_ERROR \
236 if (ctxt->error != XPATH_EXPRESSION_OK) return
237
Daniel Veillardbed7b052001-05-19 14:59:49 +0000238/**
239 * CHECK_ERROR0:
240 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000241 * Macro to return 0 from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000242 */
Owen Taylor3473f882001-02-23 17:55:21 +0000243#define CHECK_ERROR0 \
244 if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
245
Daniel Veillardbed7b052001-05-19 14:59:49 +0000246/**
247 * XP_ERROR:
248 * @X: the error code
249 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000250 * Macro to raise an XPath error and return.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000251 */
Owen Taylor3473f882001-02-23 17:55:21 +0000252#define XP_ERROR(X) \
253 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
254 ctxt->error = (X); return; }
255
Daniel Veillardbed7b052001-05-19 14:59:49 +0000256/**
257 * XP_ERROR0:
258 * @X: the error code
259 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000260 * Macro to raise an XPath error and return 0.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000261 */
Owen Taylor3473f882001-02-23 17:55:21 +0000262#define XP_ERROR0(X) \
263 { xmlXPatherror(ctxt, __FILE__, __LINE__, X); \
264 ctxt->error = (X); return(0); }
265
Daniel Veillardbed7b052001-05-19 14:59:49 +0000266/**
267 * CHECK_TYPE:
268 * @typeval: the XPath type
269 *
270 * Macro to check that the value on top of the XPath stack is of a given
271 * type.
272 */
Owen Taylor3473f882001-02-23 17:55:21 +0000273#define CHECK_TYPE(typeval) \
274 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
275 XP_ERROR(XPATH_INVALID_TYPE)
276
Daniel Veillardbed7b052001-05-19 14:59:49 +0000277/**
Daniel Veillardf06307e2001-07-03 10:35:50 +0000278 * CHECK_TYPE0:
279 * @typeval: the XPath type
280 *
281 * Macro to check that the value on top of the XPath stack is of a given
Daniel Veillard61f26172002-03-12 18:46:39 +0000282 * type. Return(0) in case of failure
Daniel Veillardf06307e2001-07-03 10:35:50 +0000283 */
284#define CHECK_TYPE0(typeval) \
285 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
286 XP_ERROR0(XPATH_INVALID_TYPE)
287
288/**
Daniel Veillardbed7b052001-05-19 14:59:49 +0000289 * CHECK_ARITY:
290 * @x: the number of expected args
291 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000292 * Macro to check that the number of args passed to an XPath function matches.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000293 */
Owen Taylor3473f882001-02-23 17:55:21 +0000294#define CHECK_ARITY(x) \
295 if (nargs != (x)) \
296 XP_ERROR(XPATH_INVALID_ARITY);
297
Daniel Veillardbed7b052001-05-19 14:59:49 +0000298/**
299 * CAST_TO_STRING:
300 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000301 * Macro to try to cast the value on the top of the XPath stack to a string.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000302 */
Owen Taylor3473f882001-02-23 17:55:21 +0000303#define CAST_TO_STRING \
304 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
305 xmlXPathStringFunction(ctxt, 1);
306
Daniel Veillardbed7b052001-05-19 14:59:49 +0000307/**
308 * CAST_TO_NUMBER:
309 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000310 * Macro to try to cast the value on the top of the XPath stack to a number.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000311 */
Owen Taylor3473f882001-02-23 17:55:21 +0000312#define CAST_TO_NUMBER \
313 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
314 xmlXPathNumberFunction(ctxt, 1);
315
Daniel Veillardbed7b052001-05-19 14:59:49 +0000316/**
317 * CAST_TO_BOOLEAN:
318 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000319 * Macro to try to cast the value on the top of the XPath stack to a boolean.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000320 */
Owen Taylor3473f882001-02-23 17:55:21 +0000321#define CAST_TO_BOOLEAN \
322 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
323 xmlXPathBooleanFunction(ctxt, 1);
324
325/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000326 * Variable Lookup forwarding.
Owen Taylor3473f882001-02-23 17:55:21 +0000327 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000328/**
329 * xmlXPathVariableLookupFunc:
330 * @ctxt: an XPath context
331 * @name: name of the variable
332 * @ns_uri: the namespace name hosting this variable
333 *
334 * Prototype for callbacks used to plug variable lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000335 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000336 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000337 * Returns the XPath object value or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000338 */
339typedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000340 const xmlChar *name,
341 const xmlChar *ns_uri);
342
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000343XMLPUBFUN void XMLCALL
344 xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000345 xmlXPathVariableLookupFunc f,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000346 void *data);
Owen Taylor3473f882001-02-23 17:55:21 +0000347
348/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000349 * Function Lookup forwarding.
Thomas Broyerba4ad322001-07-26 16:55:21 +0000350 */
Daniel Veillard9d06d302002-01-22 18:15:52 +0000351/**
352 * xmlXPathFuncLookupFunc:
353 * @ctxt: an XPath context
354 * @name: name of the function
355 * @ns_uri: the namespace name hosting this function
356 *
357 * Prototype for callbacks used to plug function lookup in the XPath
Daniel Veillard61f26172002-03-12 18:46:39 +0000358 * engine.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000359 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000360 * Returns the XPath function or NULL if not found.
Daniel Veillard9d06d302002-01-22 18:15:52 +0000361 */
Daniel Veillard99e55eb2002-01-21 08:56:29 +0000362typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
Thomas Broyerba4ad322001-07-26 16:55:21 +0000363 const xmlChar *name,
364 const xmlChar *ns_uri);
365
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000366XMLPUBFUN void XMLCALL
367 xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
Thomas Broyerba4ad322001-07-26 16:55:21 +0000368 xmlXPathFuncLookupFunc f,
369 void *funcCtxt);
370
371/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000372 * Error reporting.
Owen Taylor3473f882001-02-23 17:55:21 +0000373 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000374XMLPUBFUN void XMLCALL
375 xmlXPatherror (xmlXPathParserContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000376 const char *file,
377 int line,
378 int no);
379
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000380#ifdef LIBXML_DEBUG_ENABLED
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000381XMLPUBFUN void XMLCALL
382 xmlXPathDebugDumpObject (FILE *output,
Owen Taylor3473f882001-02-23 17:55:21 +0000383 xmlXPathObjectPtr cur,
384 int depth);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000385XMLPUBFUN void XMLCALL
386 xmlXPathDebugDumpCompExpr(FILE *output,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000387 xmlXPathCompExprPtr comp,
388 int depth);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000389#endif
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000390/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000391 * NodeSet handling.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000392 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000393XMLPUBFUN int XMLCALL
394 xmlXPathNodeSetContains (xmlNodeSetPtr cur,
Thomas Broyerf186c822001-07-31 23:30:37 +0000395 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000396XMLPUBFUN xmlNodeSetPtr XMLCALL
397 xmlXPathDifference (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000398 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000399XMLPUBFUN xmlNodeSetPtr XMLCALL
400 xmlXPathIntersection (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000401 xmlNodeSetPtr nodes2);
402
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000403XMLPUBFUN xmlNodeSetPtr XMLCALL
404 xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
405XMLPUBFUN xmlNodeSetPtr XMLCALL
406 xmlXPathDistinct (xmlNodeSetPtr nodes);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000407
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000408XMLPUBFUN int XMLCALL
409 xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000410 xmlNodeSetPtr nodes2);
411
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000412XMLPUBFUN xmlNodeSetPtr XMLCALL
413 xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000414 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000415XMLPUBFUN xmlNodeSetPtr XMLCALL
416 xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000417 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000418XMLPUBFUN xmlNodeSetPtr XMLCALL
419 xmlXPathNodeLeading (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000420 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000421XMLPUBFUN xmlNodeSetPtr XMLCALL
422 xmlXPathLeading (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000423 xmlNodeSetPtr nodes2);
424
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000425XMLPUBFUN xmlNodeSetPtr XMLCALL
426 xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000427 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000428XMLPUBFUN xmlNodeSetPtr XMLCALL
429 xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000430 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000431XMLPUBFUN xmlNodeSetPtr XMLCALL
432 xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000433 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000434XMLPUBFUN xmlNodeSetPtr XMLCALL
435 xmlXPathTrailing (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000436 xmlNodeSetPtr nodes2);
437
438
Owen Taylor3473f882001-02-23 17:55:21 +0000439/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000440 * Extending a context.
Owen Taylor3473f882001-02-23 17:55:21 +0000441 */
442
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000443XMLPUBFUN int XMLCALL
444 xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000445 const xmlChar *prefix,
446 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000447XMLPUBFUN const xmlChar * XMLCALL
448 xmlXPathNsLookup (xmlXPathContextPtr ctxt,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000449 const xmlChar *prefix);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000450XMLPUBFUN void XMLCALL
451 xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000452
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000453XMLPUBFUN int XMLCALL
454 xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000455 const xmlChar *name,
456 xmlXPathFunction f);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000457XMLPUBFUN int XMLCALL
458 xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000459 const xmlChar *name,
460 const xmlChar *ns_uri,
461 xmlXPathFunction f);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000462XMLPUBFUN int XMLCALL
463 xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000464 const xmlChar *name,
465 xmlXPathObjectPtr value);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000466XMLPUBFUN int XMLCALL
467 xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000468 const xmlChar *name,
469 const xmlChar *ns_uri,
470 xmlXPathObjectPtr value);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000471XMLPUBFUN xmlXPathFunction XMLCALL
472 xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000473 const xmlChar *name);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000474XMLPUBFUN xmlXPathFunction XMLCALL
475 xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000476 const xmlChar *name,
477 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000478XMLPUBFUN void XMLCALL
479 xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt);
480XMLPUBFUN xmlXPathObjectPtr XMLCALL
481 xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000482 const xmlChar *name);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000483XMLPUBFUN xmlXPathObjectPtr XMLCALL
484 xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000485 const xmlChar *name,
486 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000487XMLPUBFUN void XMLCALL
488 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000489
490/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000491 * Utilities to extend XPath.
Owen Taylor3473f882001-02-23 17:55:21 +0000492 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000493XMLPUBFUN xmlXPathParserContextPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000494 xmlXPathNewParserContext (const xmlChar *str,
495 xmlXPathContextPtr ctxt);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000496XMLPUBFUN void XMLCALL
497 xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000498
Daniel Veillard61f26172002-03-12 18:46:39 +0000499/* TODO: remap to xmlXPathValuePop and Push. */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000500XMLPUBFUN xmlXPathObjectPtr XMLCALL
501 valuePop (xmlXPathParserContextPtr ctxt);
502XMLPUBFUN int XMLCALL
503 valuePush (xmlXPathParserContextPtr ctxt,
504 xmlXPathObjectPtr value);
Owen Taylor3473f882001-02-23 17:55:21 +0000505
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000506XMLPUBFUN xmlXPathObjectPtr XMLCALL
507 xmlXPathNewString (const xmlChar *val);
508XMLPUBFUN xmlXPathObjectPtr XMLCALL
509 xmlXPathNewCString (const char *val);
510XMLPUBFUN xmlXPathObjectPtr XMLCALL
511 xmlXPathWrapString (xmlChar *val);
512XMLPUBFUN xmlXPathObjectPtr XMLCALL
513 xmlXPathWrapCString (char * val);
514XMLPUBFUN xmlXPathObjectPtr XMLCALL
515 xmlXPathNewFloat (double val);
516XMLPUBFUN xmlXPathObjectPtr XMLCALL
517 xmlXPathNewBoolean (int val);
518XMLPUBFUN xmlXPathObjectPtr XMLCALL
519 xmlXPathNewNodeSet (xmlNodePtr val);
520XMLPUBFUN xmlXPathObjectPtr XMLCALL
521 xmlXPathNewValueTree (xmlNodePtr val);
522XMLPUBFUN void XMLCALL
523 xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000524 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000525XMLPUBFUN void XMLCALL
526 xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000527 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000528XMLPUBFUN void XMLCALL
529 xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
Aleksey Sanin79376ba2002-05-14 06:41:32 +0000530 xmlNodePtr node,
531 xmlNsPtr ns);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000532XMLPUBFUN void XMLCALL
533 xmlXPathNodeSetSort (xmlNodeSetPtr set);
Owen Taylor3473f882001-02-23 17:55:21 +0000534
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000535XMLPUBFUN void XMLCALL
536 xmlXPathRoot (xmlXPathParserContextPtr ctxt);
537XMLPUBFUN void XMLCALL
538 xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
539XMLPUBFUN xmlChar * XMLCALL
540 xmlXPathParseName (xmlXPathParserContextPtr ctxt);
541XMLPUBFUN xmlChar * XMLCALL
542 xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000543
544/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000545 * Existing functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000546 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000547XMLPUBFUN double XMLCALL
548 xmlXPathStringEvalNumber (const xmlChar *str);
549XMLPUBFUN int XMLCALL
550 xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
551 xmlXPathObjectPtr res);
552XMLPUBFUN void XMLCALL
553 xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt);
554XMLPUBFUN xmlNodeSetPtr XMLCALL
555 xmlXPathNodeSetMerge (xmlNodeSetPtr val1,
556 xmlNodeSetPtr val2);
557XMLPUBFUN void XMLCALL
558 xmlXPathNodeSetDel (xmlNodeSetPtr cur,
559 xmlNodePtr val);
560XMLPUBFUN void XMLCALL
561 xmlXPathNodeSetRemove (xmlNodeSetPtr cur,
562 int val);
563XMLPUBFUN xmlXPathObjectPtr XMLCALL
564 xmlXPathNewNodeSetList (xmlNodeSetPtr val);
565XMLPUBFUN xmlXPathObjectPtr XMLCALL
566 xmlXPathWrapNodeSet (xmlNodeSetPtr val);
567XMLPUBFUN xmlXPathObjectPtr XMLCALL
568 xmlXPathWrapExternal (void *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000569
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000570XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
571XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
572XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
573XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
574XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
575XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
576XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
577XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
578XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000579
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000580XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name);
Owen Taylor3473f882001-02-23 17:55:21 +0000581
582/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000583 * Some of the axis navigation routines.
Owen Taylor3473f882001-02-23 17:55:21 +0000584 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000585XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000586 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000587XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000588 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000589XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000590 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000591XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000592 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000593XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000594 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000595XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000596 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000597XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000598 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000599XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000600 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000601XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000602 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000603XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000604 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000605XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000606 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000607XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000608 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000609XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000610 xmlNodePtr cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000611/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000612 * The official core of XPath functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000613 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000614XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
615XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
616XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
617XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
618XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
619XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
620XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
621XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
622XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
623XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
624XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
625XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
626XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
627XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
628XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
629XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
630XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
631XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
632XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
633XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
634XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
635XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
636XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
637XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
638XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
639XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000640
641/**
642 * Really internal functions
643 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000644XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000645
Owen Taylor3473f882001-02-23 17:55:21 +0000646#ifdef __cplusplus
647}
648#endif
649#endif /* ! __XML_XPATH_INTERNALS_H__ */