blob: 75e5d742f8d9e19041bbc3cec659bcf31f415a25 [file] [log] [blame]
Owen Taylor3473f882001-02-23 17:55:21 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: internal interfaces for XML Path Language implementation
3 * Description: internal interfaces for XML Path Language implementation
4 * used to build new modules on top of XPath like XPointer and
5 * XSLT
Owen Taylor3473f882001-02-23 17:55:21 +00006 *
Daniel Veillardbe586972003-11-18 20:56:51 +00007 * Copy: See Copyright for the status of this software.
Owen Taylor3473f882001-02-23 17:55:21 +00008 *
Daniel Veillardbe586972003-11-18 20:56:51 +00009 * Author: Daniel Veillard
Owen Taylor3473f882001-02-23 17:55:21 +000010 */
11
12#ifndef __XML_XPATH_INTERNALS_H__
13#define __XML_XPATH_INTERNALS_H__
14
Daniel Veillard017b1082001-06-21 11:20:21 +000015#include <libxml/xmlversion.h>
Owen Taylor3473f882001-02-23 17:55:21 +000016#include <libxml/xpath.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/************************************************************************
23 * *
24 * Helpers *
25 * *
26 ************************************************************************/
27
William M. Brack60f394e2003-11-16 06:25:42 +000028/*
Daniel Veillard8fcc4942001-07-17 20:07:33 +000029 * Many of these macros may later turn into functions. They
30 * shouldn't be used in #ifdef's preprocessor instructions.
31 */
Thomas Broyerf06a3d82001-07-16 04:52:57 +000032/**
33 * xmlXPathSetError:
34 * @ctxt: an XPath parser context
35 * @err: an xmlXPathError code
36 *
37 * Raises an error.
38 */
39#define xmlXPathSetError(ctxt, err) \
40 { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \
41 (ctxt)->error = (err); }
Daniel Veillard8fcc4942001-07-17 20:07:33 +000042
Thomas Broyerf06a3d82001-07-16 04:52:57 +000043/**
44 * xmlXPathSetArityError:
45 * @ctxt: an XPath parser context
46 *
Daniel Veillard61f26172002-03-12 18:46:39 +000047 * Raises an XPATH_INVALID_ARITY error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000048 */
49#define xmlXPathSetArityError(ctxt) \
50 xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000051
Thomas Broyerf06a3d82001-07-16 04:52:57 +000052/**
53 * xmlXPathSetTypeError:
54 * @ctxt: an XPath parser context
55 *
Daniel Veillard61f26172002-03-12 18:46:39 +000056 * Raises an XPATH_INVALID_TYPE error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000057 */
58#define xmlXPathSetTypeError(ctxt) \
59 xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000060
Thomas Broyerf06a3d82001-07-16 04:52:57 +000061/**
62 * xmlXPathGetError:
63 * @ctxt: an XPath parser context
64 *
Daniel Veillard61f26172002-03-12 18:46:39 +000065 * Get the error code of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000066 *
Daniel Veillard61f26172002-03-12 18:46:39 +000067 * Returns the context error.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000068 */
69#define xmlXPathGetError(ctxt) ((ctxt)->error)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000070
Thomas Broyerf06a3d82001-07-16 04:52:57 +000071/**
72 * xmlXPathCheckError:
73 * @ctxt: an XPath parser context
74 *
Daniel Veillard61f26172002-03-12 18:46:39 +000075 * Check if an XPath error was raised.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000076 *
Thomas Broyerf06a3d82001-07-16 04:52:57 +000077 * Returns true if an error has been raised, false otherwise.
78 */
79#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK)
80
81/**
82 * xmlXPathGetDocument:
83 * @ctxt: an XPath parser context
84 *
Daniel Veillard61f26172002-03-12 18:46:39 +000085 * Get the document of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000086 *
Daniel Veillard61f26172002-03-12 18:46:39 +000087 * Returns the context document.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000088 */
89#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc)
Daniel Veillard8fcc4942001-07-17 20:07:33 +000090
Thomas Broyerf06a3d82001-07-16 04:52:57 +000091/**
92 * xmlXPathGetContextNode:
93 * @ctxt: an XPath parser context
94 *
Daniel Veillard61f26172002-03-12 18:46:39 +000095 * Get the context node of an XPath context.
Daniel Veillard5e2dace2001-07-18 19:30:27 +000096 *
Daniel Veillard61f26172002-03-12 18:46:39 +000097 * Returns the context node.
Thomas Broyerf06a3d82001-07-16 04:52:57 +000098 */
99#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node)
100
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000101XMLPUBFUN int XMLCALL
102 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
103XMLPUBFUN double XMLCALL
104 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
105XMLPUBFUN xmlChar * XMLCALL
106 xmlXPathPopString (xmlXPathParserContextPtr ctxt);
107XMLPUBFUN xmlNodeSetPtr XMLCALL
108 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
109XMLPUBFUN void * XMLCALL
110 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000111
112/**
113 * xmlXPathReturnBoolean:
114 * @ctxt: an XPath parser context
115 * @val: a boolean
116 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000117 * Pushes the boolean @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000118 */
119#define xmlXPathReturnBoolean(ctxt, val) \
120 valuePush((ctxt), xmlXPathNewBoolean(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000121
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000122/**
123 * xmlXPathReturnTrue:
124 * @ctxt: an XPath parser context
125 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000126 * Pushes true on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000127 */
128#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000129
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000130/**
131 * xmlXPathReturnFalse:
132 * @ctxt: an XPath parser context
133 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000134 * Pushes false on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000135 */
136#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0)
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000137
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000138/**
139 * xmlXPathReturnNumber:
140 * @ctxt: an XPath parser context
141 * @val: a double
142 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000143 * Pushes the double @val on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000144 */
145#define xmlXPathReturnNumber(ctxt, val) \
146 valuePush((ctxt), xmlXPathNewFloat(val))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000147
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000148/**
149 * xmlXPathReturnString:
150 * @ctxt: an XPath parser context
151 * @str: a string
152 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000153 * Pushes the string @str on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000154 */
155#define xmlXPathReturnString(ctxt, str) \
William M. Brack09428a32003-12-20 09:20:39 +0000156 valuePush((ctxt), xmlXPathWrapString(str))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000157
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000158/**
159 * xmlXPathReturnEmptyString:
160 * @ctxt: an XPath parser context
161 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000162 * Pushes an empty string on the stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000163 */
164#define xmlXPathReturnEmptyString(ctxt) \
165 valuePush((ctxt), xmlXPathNewCString(""))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000166
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000167/**
168 * xmlXPathReturnNodeSet:
169 * @ctxt: an XPath parser context
170 * @ns: a node-set
171 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000172 * Pushes the node-set @ns on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000173 */
174#define xmlXPathReturnNodeSet(ctxt, ns) \
175 valuePush((ctxt), xmlXPathWrapNodeSet(ns))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000176
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000177/**
178 * xmlXPathReturnEmptyNodeSet:
179 * @ctxt: an XPath parser context
180 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000181 * Pushes an empty node-set on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000182 */
Daniel Veillard5344c602001-12-31 16:37:34 +0000183#define xmlXPathReturnEmptyNodeSet(ctxt) \
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000184 valuePush((ctxt), xmlXPathNewNodeSet(NULL))
Daniel Veillard8fcc4942001-07-17 20:07:33 +0000185
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000186/**
187 * xmlXPathReturnExternal:
188 * @ctxt: an XPath parser context
189 * @val: user data
190 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000191 * Pushes user data on the context stack.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000192 */
193#define xmlXPathReturnExternal(ctxt, val) \
194 valuePush((ctxt), xmlXPathWrapExternal(val))
195
196/**
197 * xmlXPathStackIsNodeSet:
198 * @ctxt: an XPath parser context
199 *
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000200 * Check if the current value on the XPath stack is a node set or
Daniel Veillard61f26172002-03-12 18:46:39 +0000201 * an XSLT value tree.
Daniel Veillard5e2dace2001-07-18 19:30:27 +0000202 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000203 * Returns true if the current object on the stack is a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000204 */
205#define xmlXPathStackIsNodeSet(ctxt) \
206 (((ctxt)->value != NULL) \
207 && (((ctxt)->value->type == XPATH_NODESET) \
208 || ((ctxt)->value->type == XPATH_XSLT_TREE)))
209
210/**
Thomas Broyer47334c02001-10-07 16:41:52 +0000211 * xmlXPathStackIsExternal:
212 * @ctxt: an XPath parser context
213 *
214 * Checks if the current value on the XPath stack is an external
215 * object.
216 *
217 * Returns true if the current object on the stack is an external
Daniel Veillard61f26172002-03-12 18:46:39 +0000218 * object.
Thomas Broyer47334c02001-10-07 16:41:52 +0000219 */
220#define xmlXPathStackIsExternal(ctxt) \
221 ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))
222
223/**
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000224 * xmlXPathEmptyNodeSet:
225 * @ns: a node-set
226 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000227 * Empties a node-set.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000228 */
229#define xmlXPathEmptyNodeSet(ns) \
230 { while ((ns)->nodeNr > 0) (ns)->nodeTab[(ns)->nodeNr--] = NULL; }
231
Daniel Veillardbed7b052001-05-19 14:59:49 +0000232/**
233 * CHECK_ERROR:
234 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000235 * Macro to return from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000236 */
Owen Taylor3473f882001-02-23 17:55:21 +0000237#define CHECK_ERROR \
238 if (ctxt->error != XPATH_EXPRESSION_OK) return
239
Daniel Veillardbed7b052001-05-19 14:59:49 +0000240/**
241 * CHECK_ERROR0:
242 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000243 * Macro to return 0 from the function if an XPath error was detected.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000244 */
Owen Taylor3473f882001-02-23 17:55:21 +0000245#define CHECK_ERROR0 \
246 if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
247
Daniel Veillardbed7b052001-05-19 14:59:49 +0000248/**
249 * XP_ERROR:
250 * @X: the error code
251 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000252 * Macro to raise an XPath error and return.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000253 */
Owen Taylor3473f882001-02-23 17:55:21 +0000254#define XP_ERROR(X) \
Daniel Veillardd96f6d32003-10-07 21:25:12 +0000255 { xmlXPathErr(ctxt, X); return; }
Owen Taylor3473f882001-02-23 17:55:21 +0000256
Daniel Veillardbed7b052001-05-19 14:59:49 +0000257/**
258 * XP_ERROR0:
259 * @X: the error code
260 *
Daniel Veillard61f26172002-03-12 18:46:39 +0000261 * Macro to raise an XPath error and return 0.
Daniel Veillardbed7b052001-05-19 14:59:49 +0000262 */
Owen Taylor3473f882001-02-23 17:55:21 +0000263#define XP_ERROR0(X) \
Daniel Veillardd96f6d32003-10-07 21:25:12 +0000264 { xmlXPathErr(ctxt, X); return(0); }
Owen Taylor3473f882001-02-23 17:55:21 +0000265
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 Veillardd96f6d32003-10-07 21:25:12 +0000380XMLPUBFUN void XMLCALL
381 xmlXPathErr (xmlXPathParserContextPtr ctxt,
382 int error);
383
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000384#ifdef LIBXML_DEBUG_ENABLED
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000385XMLPUBFUN void XMLCALL
386 xmlXPathDebugDumpObject (FILE *output,
Owen Taylor3473f882001-02-23 17:55:21 +0000387 xmlXPathObjectPtr cur,
388 int depth);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000389XMLPUBFUN void XMLCALL
390 xmlXPathDebugDumpCompExpr(FILE *output,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000391 xmlXPathCompExprPtr comp,
392 int depth);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000393#endif
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000394/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000395 * NodeSet handling.
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000396 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000397XMLPUBFUN int XMLCALL
398 xmlXPathNodeSetContains (xmlNodeSetPtr cur,
Thomas Broyerf186c822001-07-31 23:30:37 +0000399 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000400XMLPUBFUN xmlNodeSetPtr XMLCALL
401 xmlXPathDifference (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000402 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000403XMLPUBFUN xmlNodeSetPtr XMLCALL
404 xmlXPathIntersection (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000405 xmlNodeSetPtr nodes2);
406
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000407XMLPUBFUN xmlNodeSetPtr XMLCALL
408 xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
409XMLPUBFUN xmlNodeSetPtr XMLCALL
410 xmlXPathDistinct (xmlNodeSetPtr nodes);
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000411
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000412XMLPUBFUN int XMLCALL
413 xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000414 xmlNodeSetPtr nodes2);
415
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000416XMLPUBFUN xmlNodeSetPtr XMLCALL
417 xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000418 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000419XMLPUBFUN xmlNodeSetPtr XMLCALL
420 xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000421 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000422XMLPUBFUN xmlNodeSetPtr XMLCALL
423 xmlXPathNodeLeading (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000424 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000425XMLPUBFUN xmlNodeSetPtr XMLCALL
426 xmlXPathLeading (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000427 xmlNodeSetPtr nodes2);
428
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000429XMLPUBFUN xmlNodeSetPtr XMLCALL
430 xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000431 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000432XMLPUBFUN xmlNodeSetPtr XMLCALL
433 xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000434 xmlNodeSetPtr nodes2);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000435XMLPUBFUN xmlNodeSetPtr XMLCALL
436 xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000437 xmlNodePtr node);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000438XMLPUBFUN xmlNodeSetPtr XMLCALL
439 xmlXPathTrailing (xmlNodeSetPtr nodes1,
Thomas Broyerf06a3d82001-07-16 04:52:57 +0000440 xmlNodeSetPtr nodes2);
441
442
Owen Taylor3473f882001-02-23 17:55:21 +0000443/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000444 * Extending a context.
Owen Taylor3473f882001-02-23 17:55:21 +0000445 */
446
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000447XMLPUBFUN int XMLCALL
448 xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000449 const xmlChar *prefix,
450 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000451XMLPUBFUN const xmlChar * XMLCALL
452 xmlXPathNsLookup (xmlXPathContextPtr ctxt,
Daniel Veillardcbaf3992001-12-31 16:16:02 +0000453 const xmlChar *prefix);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000454XMLPUBFUN void XMLCALL
455 xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000456
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000457XMLPUBFUN int XMLCALL
458 xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000459 const xmlChar *name,
460 xmlXPathFunction f);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000461XMLPUBFUN int XMLCALL
462 xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000463 const xmlChar *name,
464 const xmlChar *ns_uri,
465 xmlXPathFunction f);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000466XMLPUBFUN int XMLCALL
467 xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000468 const xmlChar *name,
469 xmlXPathObjectPtr value);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000470XMLPUBFUN int XMLCALL
471 xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000472 const xmlChar *name,
473 const xmlChar *ns_uri,
474 xmlXPathObjectPtr value);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000475XMLPUBFUN xmlXPathFunction XMLCALL
476 xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000477 const xmlChar *name);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000478XMLPUBFUN xmlXPathFunction XMLCALL
479 xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000480 const xmlChar *name,
481 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000482XMLPUBFUN void XMLCALL
483 xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt);
484XMLPUBFUN xmlXPathObjectPtr XMLCALL
485 xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000486 const xmlChar *name);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000487XMLPUBFUN xmlXPathObjectPtr XMLCALL
488 xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
Owen Taylor3473f882001-02-23 17:55:21 +0000489 const xmlChar *name,
490 const xmlChar *ns_uri);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000491XMLPUBFUN void XMLCALL
492 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000493
494/**
Daniel Veillard61f26172002-03-12 18:46:39 +0000495 * Utilities to extend XPath.
Owen Taylor3473f882001-02-23 17:55:21 +0000496 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000497XMLPUBFUN xmlXPathParserContextPtr XMLCALL
Owen Taylor3473f882001-02-23 17:55:21 +0000498 xmlXPathNewParserContext (const xmlChar *str,
499 xmlXPathContextPtr ctxt);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000500XMLPUBFUN void XMLCALL
501 xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000502
Daniel Veillard61f26172002-03-12 18:46:39 +0000503/* TODO: remap to xmlXPathValuePop and Push. */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000504XMLPUBFUN xmlXPathObjectPtr XMLCALL
505 valuePop (xmlXPathParserContextPtr ctxt);
506XMLPUBFUN int XMLCALL
507 valuePush (xmlXPathParserContextPtr ctxt,
508 xmlXPathObjectPtr value);
Owen Taylor3473f882001-02-23 17:55:21 +0000509
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000510XMLPUBFUN xmlXPathObjectPtr XMLCALL
511 xmlXPathNewString (const xmlChar *val);
512XMLPUBFUN xmlXPathObjectPtr XMLCALL
513 xmlXPathNewCString (const char *val);
514XMLPUBFUN xmlXPathObjectPtr XMLCALL
515 xmlXPathWrapString (xmlChar *val);
516XMLPUBFUN xmlXPathObjectPtr XMLCALL
517 xmlXPathWrapCString (char * val);
518XMLPUBFUN xmlXPathObjectPtr XMLCALL
519 xmlXPathNewFloat (double val);
520XMLPUBFUN xmlXPathObjectPtr XMLCALL
521 xmlXPathNewBoolean (int val);
522XMLPUBFUN xmlXPathObjectPtr XMLCALL
523 xmlXPathNewNodeSet (xmlNodePtr val);
524XMLPUBFUN xmlXPathObjectPtr XMLCALL
525 xmlXPathNewValueTree (xmlNodePtr val);
526XMLPUBFUN void XMLCALL
527 xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
Owen Taylor3473f882001-02-23 17:55:21 +0000528 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000529XMLPUBFUN void XMLCALL
530 xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000531 xmlNodePtr val);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000532XMLPUBFUN void XMLCALL
533 xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
Aleksey Sanin79376ba2002-05-14 06:41:32 +0000534 xmlNodePtr node,
535 xmlNsPtr ns);
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000536XMLPUBFUN void XMLCALL
537 xmlXPathNodeSetSort (xmlNodeSetPtr set);
Owen Taylor3473f882001-02-23 17:55:21 +0000538
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000539XMLPUBFUN void XMLCALL
540 xmlXPathRoot (xmlXPathParserContextPtr ctxt);
541XMLPUBFUN void XMLCALL
542 xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
543XMLPUBFUN xmlChar * XMLCALL
544 xmlXPathParseName (xmlXPathParserContextPtr ctxt);
545XMLPUBFUN xmlChar * XMLCALL
546 xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000547
548/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000549 * Existing functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000550 */
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000551XMLPUBFUN double XMLCALL
552 xmlXPathStringEvalNumber (const xmlChar *str);
553XMLPUBFUN int XMLCALL
554 xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
555 xmlXPathObjectPtr res);
556XMLPUBFUN void XMLCALL
557 xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt);
558XMLPUBFUN xmlNodeSetPtr XMLCALL
559 xmlXPathNodeSetMerge (xmlNodeSetPtr val1,
560 xmlNodeSetPtr val2);
561XMLPUBFUN void XMLCALL
562 xmlXPathNodeSetDel (xmlNodeSetPtr cur,
563 xmlNodePtr val);
564XMLPUBFUN void XMLCALL
565 xmlXPathNodeSetRemove (xmlNodeSetPtr cur,
566 int val);
567XMLPUBFUN xmlXPathObjectPtr XMLCALL
568 xmlXPathNewNodeSetList (xmlNodeSetPtr val);
569XMLPUBFUN xmlXPathObjectPtr XMLCALL
570 xmlXPathWrapNodeSet (xmlNodeSetPtr val);
571XMLPUBFUN xmlXPathObjectPtr XMLCALL
572 xmlXPathWrapExternal (void *val);
Owen Taylor3473f882001-02-23 17:55:21 +0000573
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000574XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
575XMLPUBFUN int XMLCALL xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
576XMLPUBFUN int XMLCALL xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
577XMLPUBFUN void XMLCALL xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
578XMLPUBFUN void XMLCALL xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
579XMLPUBFUN void XMLCALL xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
580XMLPUBFUN void XMLCALL xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
581XMLPUBFUN void XMLCALL xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
582XMLPUBFUN void XMLCALL xmlXPathModValues(xmlXPathParserContextPtr ctxt);
Owen Taylor3473f882001-02-23 17:55:21 +0000583
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000584XMLPUBFUN int XMLCALL xmlXPathIsNodeType(const xmlChar *name);
Owen Taylor3473f882001-02-23 17:55:21 +0000585
586/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000587 * Some of the axis navigation routines.
Owen Taylor3473f882001-02-23 17:55:21 +0000588 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000589XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000590 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000591XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000592 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000593XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000594 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000595XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000596 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000597XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000598 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000599XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000600 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000601XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000602 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000603XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000604 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000605XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000606 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000607XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000608 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000609XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000610 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000611XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000612 xmlNodePtr cur);
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000613XMLPUBFUN xmlNodePtr XMLCALL xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
Daniel Veillard56a4cb82001-03-24 17:00:36 +0000614 xmlNodePtr cur);
Owen Taylor3473f882001-02-23 17:55:21 +0000615/*
Daniel Veillard61f26172002-03-12 18:46:39 +0000616 * The official core of XPath functions.
Owen Taylor3473f882001-02-23 17:55:21 +0000617 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000618XMLPUBFUN void XMLCALL xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
619XMLPUBFUN void XMLCALL xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
620XMLPUBFUN void XMLCALL xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
621XMLPUBFUN void XMLCALL xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
622XMLPUBFUN void XMLCALL xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
623XMLPUBFUN void XMLCALL xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
624XMLPUBFUN void XMLCALL xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
625XMLPUBFUN void XMLCALL xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
626XMLPUBFUN void XMLCALL xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
627XMLPUBFUN void XMLCALL xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
628XMLPUBFUN void XMLCALL xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
629XMLPUBFUN void XMLCALL xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
630XMLPUBFUN void XMLCALL xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
631XMLPUBFUN void XMLCALL xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
632XMLPUBFUN void XMLCALL xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
633XMLPUBFUN void XMLCALL xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
634XMLPUBFUN void XMLCALL xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
635XMLPUBFUN void XMLCALL xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
636XMLPUBFUN void XMLCALL xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
637XMLPUBFUN void XMLCALL xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
638XMLPUBFUN void XMLCALL xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
639XMLPUBFUN void XMLCALL xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
640XMLPUBFUN void XMLCALL xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
641XMLPUBFUN void XMLCALL xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
642XMLPUBFUN void XMLCALL xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
643XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000644
645/**
646 * Really internal functions
647 */
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000648XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns);
Aleksey Saninf8cb6dd2002-06-04 04:27:06 +0000649
Owen Taylor3473f882001-02-23 17:55:21 +0000650#ifdef __cplusplus
651}
652#endif
653#endif /* ! __XML_XPATH_INTERNALS_H__ */