williamr@4
|
1 |
/*
|
williamr@4
|
2 |
* Summary: XML Path Language implementation
|
williamr@4
|
3 |
* Description: API for the XML Path Language implementation
|
williamr@4
|
4 |
*
|
williamr@4
|
5 |
* XML Path Language implementation
|
williamr@4
|
6 |
* XPath is a language for addressing parts of an XML document,
|
williamr@4
|
7 |
* designed to be used by both XSLT and XPointer
|
williamr@4
|
8 |
* http://www.w3.org/TR/xpath
|
williamr@4
|
9 |
*
|
williamr@4
|
10 |
* Implements
|
williamr@4
|
11 |
* W3C Recommendation 16 November 1999
|
williamr@4
|
12 |
* http://www.w3.org/TR/1999/REC-xpath-19991116
|
williamr@4
|
13 |
*
|
williamr@4
|
14 |
* Copy: See Copyright for the status of this software.
|
williamr@4
|
15 |
*
|
williamr@4
|
16 |
* Author: Daniel Veillard
|
williamr@4
|
17 |
* Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
williamr@4
|
18 |
*/
|
williamr@4
|
19 |
|
williamr@4
|
20 |
/** @file
|
williamr@4
|
21 |
@publishedAll
|
williamr@4
|
22 |
@released
|
williamr@4
|
23 |
*/
|
williamr@4
|
24 |
|
williamr@4
|
25 |
#ifndef XML_XPATH_H
|
williamr@4
|
26 |
#define XML_XPATH_H
|
williamr@4
|
27 |
|
williamr@4
|
28 |
#include <stdapis/libxml2/libxml2_hash.h>
|
williamr@4
|
29 |
#include <stdapis/libxml2/libxml2_dict.h>
|
williamr@4
|
30 |
#include <stdapis/libxml2/libxml2_xmlerror.h>
|
williamr@4
|
31 |
|
williamr@4
|
32 |
#ifdef __cplusplus
|
williamr@4
|
33 |
extern "C" {
|
williamr@4
|
34 |
#endif
|
williamr@4
|
35 |
|
williamr@4
|
36 |
|
williamr@4
|
37 |
typedef struct _xmlXPathContext xmlXPathContext;
|
williamr@4
|
38 |
typedef xmlXPathContext *xmlXPathContextPtr;
|
williamr@4
|
39 |
typedef struct _xmlXPathParserContext xmlXPathParserContext;
|
williamr@4
|
40 |
typedef xmlXPathParserContext *xmlXPathParserContextPtr;
|
williamr@4
|
41 |
|
williamr@4
|
42 |
/**
|
williamr@4
|
43 |
* The set of XPath error codes.
|
williamr@4
|
44 |
*/
|
williamr@4
|
45 |
typedef enum {
|
williamr@4
|
46 |
XPATH_EXPRESSION_OK = 0,
|
williamr@4
|
47 |
XPATH_NUMBER_ERROR,
|
williamr@4
|
48 |
XPATH_UNFINISHED_LITERAL_ERROR,
|
williamr@4
|
49 |
XPATH_START_LITERAL_ERROR,
|
williamr@4
|
50 |
XPATH_VARIABLE_REF_ERROR,
|
williamr@4
|
51 |
XPATH_UNDEF_VARIABLE_ERROR,
|
williamr@4
|
52 |
XPATH_INVALID_PREDICATE_ERROR,
|
williamr@4
|
53 |
XPATH_EXPR_ERROR,
|
williamr@4
|
54 |
XPATH_UNCLOSED_ERROR,
|
williamr@4
|
55 |
XPATH_UNKNOWN_FUNC_ERROR,
|
williamr@4
|
56 |
XPATH_INVALID_OPERAND,
|
williamr@4
|
57 |
XPATH_INVALID_TYPE,
|
williamr@4
|
58 |
XPATH_INVALID_ARITY,
|
williamr@4
|
59 |
XPATH_INVALID_CTXT_SIZE,
|
williamr@4
|
60 |
XPATH_INVALID_CTXT_POSITION,
|
williamr@4
|
61 |
XPATH_MEMORY_ERROR,
|
williamr@4
|
62 |
XPTR_SYNTAX_ERROR,
|
williamr@4
|
63 |
XPTR_RESOURCE_ERROR,
|
williamr@4
|
64 |
XPTR_SUB_RESOURCE_ERROR,
|
williamr@4
|
65 |
XPATH_UNDEF_PREFIX_ERROR,
|
williamr@4
|
66 |
XPATH_ENCODING_ERROR,
|
williamr@4
|
67 |
XPATH_INVALID_CHAR_ERROR,
|
williamr@4
|
68 |
XPATH_XE_EXTENSION_FUNC_ERROR
|
williamr@4
|
69 |
} xmlXPathError;
|
williamr@4
|
70 |
|
williamr@4
|
71 |
/*
|
williamr@4
|
72 |
* A node-set (an unordered collection of nodes without duplicates).
|
williamr@4
|
73 |
*/
|
williamr@4
|
74 |
typedef struct _xmlNodeSet xmlNodeSet;
|
williamr@4
|
75 |
typedef xmlNodeSet *xmlNodeSetPtr;
|
williamr@4
|
76 |
struct _xmlNodeSet {
|
williamr@4
|
77 |
int nodeNr; /* number of nodes in the set */
|
williamr@4
|
78 |
int nodeMax; /* size of the array as allocated */
|
williamr@4
|
79 |
xmlNodePtr* nodeTab; /* array of nodes in no particular order */
|
williamr@4
|
80 |
/* @@ with_ns to check wether namespace nodes should be looked at @@ */
|
williamr@4
|
81 |
};
|
williamr@4
|
82 |
|
williamr@4
|
83 |
/*
|
williamr@4
|
84 |
* An expression is evaluated to yield an object, which
|
williamr@4
|
85 |
* has one of the following four basic types:
|
williamr@4
|
86 |
* - node-set
|
williamr@4
|
87 |
* - boolean
|
williamr@4
|
88 |
* - number
|
williamr@4
|
89 |
* - string
|
williamr@4
|
90 |
*
|
williamr@4
|
91 |
* @@ XPointer will add more types !
|
williamr@4
|
92 |
*/
|
williamr@4
|
93 |
|
williamr@4
|
94 |
typedef enum {
|
williamr@4
|
95 |
XPATH_UNDEFINED = 0,
|
williamr@4
|
96 |
XPATH_NODESET = 1,
|
williamr@4
|
97 |
XPATH_BOOLEAN = 2,
|
williamr@4
|
98 |
XPATH_NUMBER = 3,
|
williamr@4
|
99 |
XPATH_STRING = 4,
|
williamr@4
|
100 |
XPATH_POINT = 5,
|
williamr@4
|
101 |
XPATH_RANGE = 6,
|
williamr@4
|
102 |
XPATH_LOCATIONSET = 7,
|
williamr@4
|
103 |
XPATH_USERS = 8,
|
williamr@4
|
104 |
XPATH_XSLT_TREE = 9 /* An XSLT value tree, non modifiable */
|
williamr@4
|
105 |
} xmlXPathObjectType;
|
williamr@4
|
106 |
|
williamr@4
|
107 |
typedef struct _xmlXPathObject xmlXPathObject;
|
williamr@4
|
108 |
typedef xmlXPathObject *xmlXPathObjectPtr;
|
williamr@4
|
109 |
struct _xmlXPathObject {
|
williamr@4
|
110 |
xmlXPathObjectType type;
|
williamr@4
|
111 |
xmlNodeSetPtr nodesetval;
|
williamr@4
|
112 |
int boolval;
|
williamr@4
|
113 |
double floatval;
|
williamr@4
|
114 |
xmlChar* stringval;
|
williamr@4
|
115 |
void* user;
|
williamr@4
|
116 |
int index;
|
williamr@4
|
117 |
void* user2;
|
williamr@4
|
118 |
int index2;
|
williamr@4
|
119 |
};
|
williamr@4
|
120 |
|
williamr@4
|
121 |
/**
|
williamr@4
|
122 |
* xmlXPathConvertFunc:
|
williamr@4
|
123 |
* @param obj an XPath object
|
williamr@4
|
124 |
* @param type the number of the target type
|
williamr@4
|
125 |
*
|
williamr@4
|
126 |
* A conversion function is associated to a type and used to cast
|
williamr@4
|
127 |
* the new type to primitive values.
|
williamr@4
|
128 |
*
|
williamr@4
|
129 |
* Returns -1 in case of error, 0 otherwise
|
williamr@4
|
130 |
*/
|
williamr@4
|
131 |
typedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);
|
williamr@4
|
132 |
|
williamr@4
|
133 |
/*
|
williamr@4
|
134 |
* Extra type: a name and a conversion function.
|
williamr@4
|
135 |
*/
|
williamr@4
|
136 |
|
williamr@4
|
137 |
typedef struct _xmlXPathType xmlXPathType;
|
williamr@4
|
138 |
typedef xmlXPathType *xmlXPathTypePtr;
|
williamr@4
|
139 |
struct _xmlXPathType {
|
williamr@4
|
140 |
const xmlChar *name; /* the type name */
|
williamr@4
|
141 |
xmlXPathConvertFunc func; /* the conversion function */
|
williamr@4
|
142 |
};
|
williamr@4
|
143 |
|
williamr@4
|
144 |
/*
|
williamr@4
|
145 |
* Extra variable: a name and a value.
|
williamr@4
|
146 |
*/
|
williamr@4
|
147 |
|
williamr@4
|
148 |
typedef struct _xmlXPathVariable xmlXPathVariable;
|
williamr@4
|
149 |
typedef xmlXPathVariable *xmlXPathVariablePtr;
|
williamr@4
|
150 |
struct _xmlXPathVariable {
|
williamr@4
|
151 |
const xmlChar *name; /* the variable name */
|
williamr@4
|
152 |
xmlXPathObjectPtr value; /* the value */
|
williamr@4
|
153 |
};
|
williamr@4
|
154 |
|
williamr@4
|
155 |
/**
|
williamr@4
|
156 |
* xmlXPathEvalFunc:
|
williamr@4
|
157 |
* @param ctxt an XPath parser context
|
williamr@4
|
158 |
* @param nargs the number of arguments passed to the function
|
williamr@4
|
159 |
*
|
williamr@4
|
160 |
* An XPath evaluation function, the parameters are on the XPath context stack.
|
williamr@4
|
161 |
*/
|
williamr@4
|
162 |
|
williamr@4
|
163 |
typedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt, int nargs);
|
williamr@4
|
164 |
|
williamr@4
|
165 |
/*
|
williamr@4
|
166 |
* Extra function: a name and a evaluation function.
|
williamr@4
|
167 |
*/
|
williamr@4
|
168 |
|
williamr@4
|
169 |
typedef struct _xmlXPathFunct xmlXPathFunct;
|
williamr@4
|
170 |
typedef xmlXPathFunct *xmlXPathFuncPtr;
|
williamr@4
|
171 |
struct _xmlXPathFunct {
|
williamr@4
|
172 |
const xmlChar *name; /* the function name */
|
williamr@4
|
173 |
xmlXPathEvalFunc func; /* the evaluation function */
|
williamr@4
|
174 |
};
|
williamr@4
|
175 |
|
williamr@4
|
176 |
/**
|
williamr@4
|
177 |
* xmlXPathAxisFunc:
|
williamr@4
|
178 |
* @param ctxt the XPath interpreter context
|
williamr@4
|
179 |
* @param cur the previous node being explored on that axis
|
williamr@4
|
180 |
*
|
williamr@4
|
181 |
* An axis traversal function. To traverse an axis, the engine calls
|
williamr@4
|
182 |
* the first time with cur == NULL and repeat until the function returns
|
williamr@4
|
183 |
* NULL indicating the end of the axis traversal.
|
williamr@4
|
184 |
*
|
williamr@4
|
185 |
* Returns the next node in that axis or NULL if at the end of the axis.
|
williamr@4
|
186 |
*/
|
williamr@4
|
187 |
|
williamr@4
|
188 |
typedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr cur);
|
williamr@4
|
189 |
|
williamr@4
|
190 |
/*
|
williamr@4
|
191 |
* Extra axis: a name and an axis function.
|
williamr@4
|
192 |
*/
|
williamr@4
|
193 |
|
williamr@4
|
194 |
typedef struct _xmlXPathAxis xmlXPathAxis;
|
williamr@4
|
195 |
typedef xmlXPathAxis* xmlXPathAxisPtr;
|
williamr@4
|
196 |
struct _xmlXPathAxis {
|
williamr@4
|
197 |
const xmlChar* name; /* the axis name */
|
williamr@4
|
198 |
xmlXPathAxisFunc func; /* the search function */
|
williamr@4
|
199 |
};
|
williamr@4
|
200 |
|
williamr@4
|
201 |
// XMLENGINE: NEW CODE -- XForms extensions support
|
williamr@4
|
202 |
/**
|
williamr@4
|
203 |
Callback for resolving prefix names into namespace URIs
|
williamr@4
|
204 |
|
williamr@4
|
205 |
@return Namespace URI for aNs prefix.
|
williamr@4
|
206 |
|
williamr@4
|
207 |
Resolving is made with aCtxt context.
|
williamr@4
|
208 |
|
williamr@4
|
209 |
This function is used internally by for implementation of
|
williamr@4
|
210 |
namespace-resovling feature in XPath API of XML Engine
|
williamr@4
|
211 |
(MXmlEngNamespaceResolver interface is called by libxml2)
|
williamr@4
|
212 |
*/
|
williamr@4
|
213 |
typedef const xmlChar* (*xeXPathNsResolverFunc)(void* aCtxt, const xmlChar* aNs);
|
williamr@4
|
214 |
//---
|
williamr@4
|
215 |
|
williamr@4
|
216 |
/**
|
williamr@4
|
217 |
* xmlXPathContext:
|
williamr@4
|
218 |
*
|
williamr@4
|
219 |
* Expression evaluation occurs with respect to a context.
|
williamr@4
|
220 |
* the context consists of:
|
williamr@4
|
221 |
* - a node (the context node)
|
williamr@4
|
222 |
* - a node list (the context node list)
|
williamr@4
|
223 |
* - a set of variable bindings
|
williamr@4
|
224 |
* - a function library
|
williamr@4
|
225 |
* - the set of namespace declarations in scope for the expression
|
williamr@4
|
226 |
* Following the switch to hash tables, this need to be trimmed up at
|
williamr@4
|
227 |
* the next binary incompatible release.
|
williamr@4
|
228 |
*/
|
williamr@4
|
229 |
struct _xmlXPathContext {
|
williamr@4
|
230 |
xmlDocPtr doc; /* The current document */
|
williamr@4
|
231 |
xmlNodePtr node; /* The current node */
|
williamr@4
|
232 |
|
williamr@4
|
233 |
//int nb_variables_unused; /* unused (hash table) */
|
williamr@4
|
234 |
//int max_variables_unused; /* unused (hash table) */
|
williamr@4
|
235 |
xmlHashTablePtr varHash; /* Hash table of defined variables */
|
williamr@4
|
236 |
|
williamr@4
|
237 |
int nb_types; /* number of defined types */
|
williamr@4
|
238 |
int max_types; /* max number of types */
|
williamr@4
|
239 |
xmlXPathTypePtr types; /* Array of defined types */
|
williamr@4
|
240 |
|
williamr@4
|
241 |
//int nb_funcs_unused; /* unused (hash table) */
|
williamr@4
|
242 |
//int max_funcs_unused; /* unused (hash table) */
|
williamr@4
|
243 |
xmlHashTablePtr funcHash; /* Hash table of defined funcs */
|
williamr@4
|
244 |
|
williamr@4
|
245 |
int nb_axis; /* number of defined axis */
|
williamr@4
|
246 |
int max_axis; /* max number of axis */
|
williamr@4
|
247 |
xmlXPathAxisPtr axis; /* Array of defined axis */
|
williamr@4
|
248 |
|
williamr@4
|
249 |
/* the namespace nodes of the context node */
|
williamr@4
|
250 |
xmlNsPtr *namespaces; /* Array of namespaces */
|
williamr@4
|
251 |
int nsNr; /* number of namespace in scope */
|
williamr@4
|
252 |
void *user; /* function to free */
|
williamr@4
|
253 |
|
williamr@4
|
254 |
/* extra variables */
|
williamr@4
|
255 |
int contextSize; /* the context size */
|
williamr@4
|
256 |
int proximityPosition; /* the proximity position */
|
williamr@4
|
257 |
|
williamr@4
|
258 |
/* extra stuff for XPointer */
|
williamr@4
|
259 |
int xptr; /* it this an XPointer context */
|
williamr@4
|
260 |
xmlNodePtr here; /* for here() */
|
williamr@4
|
261 |
xmlNodePtr origin; /* for origin() */
|
williamr@4
|
262 |
|
williamr@4
|
263 |
/* the set of namespace declarations in scope for the expression */
|
williamr@4
|
264 |
xmlHashTablePtr nsHash; /* The namespaces hash table */
|
williamr@4
|
265 |
void* varLookupFunc; /* variable lookup func */
|
williamr@4
|
266 |
void* varLookupData; /* variable lookup data */
|
williamr@4
|
267 |
|
williamr@4
|
268 |
/* Possibility to link in an extra item */
|
williamr@4
|
269 |
void* extra; /* needed for XSLT */
|
williamr@4
|
270 |
|
williamr@4
|
271 |
/* The function name and URI when calling a function */
|
williamr@4
|
272 |
const xmlChar* function;
|
williamr@4
|
273 |
const xmlChar* functionURI;
|
williamr@4
|
274 |
|
williamr@4
|
275 |
/* function lookup function and data */
|
williamr@4
|
276 |
void* funcLookupFunc; /* function lookup func */
|
williamr@4
|
277 |
void* funcLookupData; /* function lookup data */
|
williamr@4
|
278 |
|
williamr@4
|
279 |
/* temporary namespace lists kept for walking the namespace axis */
|
williamr@4
|
280 |
xmlNsPtr* tmpNsList; /* Array of namespaces */
|
williamr@4
|
281 |
int tmpNsNr; /* number of namespace in scope */
|
williamr@4
|
282 |
|
williamr@4
|
283 |
/* error reporting mechanism */
|
williamr@4
|
284 |
void* userData; /* user specific data block */
|
williamr@4
|
285 |
xmlStructuredErrorFunc error; /* the callback in case of errors */
|
williamr@4
|
286 |
xmlError lastError; /* the last error */
|
williamr@4
|
287 |
xmlNodePtr debugNode; /* the source node XSLT */
|
williamr@4
|
288 |
|
williamr@4
|
289 |
/* dictionnary */
|
williamr@4
|
290 |
xmlDictPtr dict; /* dictionnary if any */
|
williamr@4
|
291 |
|
williamr@4
|
292 |
// XMLENGINE: NEW CODE -- XForms extensions support
|
williamr@4
|
293 |
xmlHashTablePtr instanceDocs; /* hash table that stores instance XForms instance docs,
|
williamr@4
|
294 |
not owned by the structure, will be freed by the client*/
|
williamr@4
|
295 |
xmlNodeSetPtr dependencyList;/* nodes that the expression depends on */
|
williamr@4
|
296 |
xeXPathNsResolverFunc xeResolveNs; /* find namespace URI bound to prefix in the current context */
|
williamr@4
|
297 |
void* xeResolveNsCtxt; /* resolver-specific context for processing */
|
williamr@4
|
298 |
// END NEW CODE
|
williamr@4
|
299 |
|
williamr@4
|
300 |
};
|
williamr@4
|
301 |
|
williamr@4
|
302 |
/*
|
williamr@4
|
303 |
* The structure of a compiled expression form has become public in XML ENGINE
|
williamr@4
|
304 |
*/
|
williamr@4
|
305 |
|
williamr@4
|
306 |
typedef enum {
|
williamr@4
|
307 |
XPATH_OP_END=0,
|
williamr@4
|
308 |
XPATH_OP_AND,
|
williamr@4
|
309 |
XPATH_OP_OR,
|
williamr@4
|
310 |
XPATH_OP_EQUAL,
|
williamr@4
|
311 |
XPATH_OP_CMP,
|
williamr@4
|
312 |
XPATH_OP_PLUS,
|
williamr@4
|
313 |
XPATH_OP_MULT,
|
williamr@4
|
314 |
XPATH_OP_UNION,
|
williamr@4
|
315 |
XPATH_OP_ROOT,
|
williamr@4
|
316 |
XPATH_OP_NODE,
|
williamr@4
|
317 |
XPATH_OP_RESET,
|
williamr@4
|
318 |
XPATH_OP_COLLECT,
|
williamr@4
|
319 |
XPATH_OP_VALUE,
|
williamr@4
|
320 |
XPATH_OP_VARIABLE,
|
williamr@4
|
321 |
XPATH_OP_FUNCTION,
|
williamr@4
|
322 |
XPATH_OP_ARG,
|
williamr@4
|
323 |
XPATH_OP_PREDICATE,
|
williamr@4
|
324 |
XPATH_OP_FILTER,
|
williamr@4
|
325 |
XPATH_OP_SORT
|
williamr@4
|
326 |
#ifdef LIBXML_XPTR_ENABLED
|
williamr@4
|
327 |
,XPATH_OP_RANGETO
|
williamr@4
|
328 |
#endif
|
williamr@4
|
329 |
} xmlXPathOp;
|
williamr@4
|
330 |
|
williamr@4
|
331 |
typedef struct _xmlXPathStepOp xmlXPathStepOp;
|
williamr@4
|
332 |
typedef xmlXPathStepOp *xmlXPathStepOpPtr;
|
williamr@4
|
333 |
struct _xmlXPathStepOp {
|
williamr@4
|
334 |
xmlXPathOp op; /* The identifier of the operation */
|
williamr@4
|
335 |
int ch1; /* First child */
|
williamr@4
|
336 |
int ch2; /* Second child */
|
williamr@4
|
337 |
int value;
|
williamr@4
|
338 |
int value2;
|
williamr@4
|
339 |
int value3;
|
williamr@4
|
340 |
void* value4;
|
williamr@4
|
341 |
void* value5;
|
williamr@4
|
342 |
void* cache;
|
williamr@4
|
343 |
void* cacheURI;
|
williamr@4
|
344 |
};
|
williamr@4
|
345 |
|
williamr@4
|
346 |
|
williamr@4
|
347 |
/**
|
williamr@4
|
348 |
The initial size of 'steps' table in the precompiled XPath exression
|
williamr@4
|
349 |
|
williamr@4
|
350 |
Double-it policy for growth is used in the code
|
williamr@4
|
351 |
*/
|
williamr@4
|
352 |
#define XPATH_STEPS_GRANULARITY 10
|
williamr@4
|
353 |
|
williamr@4
|
354 |
typedef struct _xmlXPathCompExpr xmlXPathCompExpr;
|
williamr@4
|
355 |
typedef xmlXPathCompExpr* xmlXPathCompExprPtr;
|
williamr@4
|
356 |
struct _xmlXPathCompExpr {
|
williamr@4
|
357 |
int nbStep; /* Number of steps in this expression */
|
williamr@4
|
358 |
int maxStep; /* Maximum number of steps allocated */
|
williamr@4
|
359 |
xmlXPathStepOp* steps; /* ops for computation of this expression */
|
williamr@4
|
360 |
int last; /* index of last step in expression */
|
williamr@4
|
361 |
xmlChar* expr; /* the expression being computed */
|
williamr@4
|
362 |
xmlDictPtr dict; /* the dictionnary to use if any */
|
williamr@4
|
363 |
#ifdef DEBUG_EVAL_COUNTS
|
williamr@4
|
364 |
int nb;
|
williamr@4
|
365 |
xmlChar* string;
|
williamr@4
|
366 |
#endif
|
williamr@4
|
367 |
//XMLENGINE: NEW CODE
|
williamr@4
|
368 |
void* extendedContext; /* some data set by API users and available for XPath extension functions */
|
williamr@4
|
369 |
void* xeNsResolver; /* default namespace resolver supplied when compiling expression */
|
williamr@4
|
370 |
//XMLENGINE: END NEW CODE
|
williamr@4
|
371 |
};
|
williamr@4
|
372 |
/**
|
williamr@4
|
373 |
* xmlXPathParserContext:
|
williamr@4
|
374 |
*
|
williamr@4
|
375 |
* An XPath parser context. It contains pure parsing informations,
|
williamr@4
|
376 |
* an xmlXPathContext, and the stack of objects.
|
williamr@4
|
377 |
*/
|
williamr@4
|
378 |
struct _xmlXPathParserContext {
|
williamr@4
|
379 |
const xmlChar *cur; /* the current char being parsed */
|
williamr@4
|
380 |
const xmlChar *base; /* the full expression */
|
williamr@4
|
381 |
|
williamr@4
|
382 |
int error; /* error code */
|
williamr@4
|
383 |
|
williamr@4
|
384 |
xmlXPathContextPtr context; /* the evaluation context */
|
williamr@4
|
385 |
xmlXPathObjectPtr value; /* the current value */
|
williamr@4
|
386 |
int valueNr; /* number of values stacked */
|
williamr@4
|
387 |
int valueMax; /* max number of values stacked */
|
williamr@4
|
388 |
xmlXPathObjectPtr *valueTab; /* stack of values */
|
williamr@4
|
389 |
|
williamr@4
|
390 |
xmlXPathCompExprPtr comp; /* the precompiled expression */
|
williamr@4
|
391 |
int xptr; /* it this an XPointer expression */
|
williamr@4
|
392 |
xmlNodePtr ancestor; /* used for walking preceding axis */
|
williamr@4
|
393 |
};
|
williamr@4
|
394 |
|
williamr@4
|
395 |
/**
|
williamr@4
|
396 |
* xmlXPathFunction:
|
williamr@4
|
397 |
* @param ctxt the XPath interprestation context
|
williamr@4
|
398 |
* @param nargs the number of arguments
|
williamr@4
|
399 |
*
|
williamr@4
|
400 |
* An XPath function.
|
williamr@4
|
401 |
* The arguments (if any) are popped out from the context stack
|
williamr@4
|
402 |
* and the result is pushed on the stack.
|
williamr@4
|
403 |
*/
|
williamr@4
|
404 |
|
williamr@4
|
405 |
typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
|
williamr@4
|
406 |
|
williamr@4
|
407 |
/************************************************************************
|
williamr@4
|
408 |
* *
|
williamr@4
|
409 |
* Public API *
|
williamr@4
|
410 |
* *
|
williamr@4
|
411 |
************************************************************************/
|
williamr@4
|
412 |
|
williamr@4
|
413 |
/*
|
williamr@4
|
414 |
NOTE: Now defined as local inline functions in xpath.c
|
williamr@4
|
415 |
It seems that no one uses them from outside..
|
williamr@4
|
416 |
--> used by libxslt
|
williamr@4
|
417 |
*/
|
williamr@4
|
418 |
|
williamr@4
|
419 |
#define xmlXPathIsNaN(val) trio_isnan(val)
|
williamr@4
|
420 |
#define xmlXPathIsInf(val) trio_isinf(val)
|
williamr@4
|
421 |
|
williamr@4
|
422 |
|
williamr@4
|
423 |
/* These macros may later turn into functions */
|
williamr@4
|
424 |
/**
|
williamr@4
|
425 |
* xmlXPathNodeSetGetLength:
|
williamr@4
|
426 |
* @param ns a node-set
|
williamr@4
|
427 |
*
|
williamr@4
|
428 |
* Implements a functionality similar to the DOM NodeList.length.
|
williamr@4
|
429 |
*
|
williamr@4
|
430 |
* Returns the number of nodes in the node-set.
|
williamr@4
|
431 |
*/
|
williamr@4
|
432 |
#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0)
|
williamr@4
|
433 |
/**
|
williamr@4
|
434 |
* xmlXPathNodeSetItem:
|
williamr@4
|
435 |
* @param ns a node-set
|
williamr@4
|
436 |
* @param index index of a node in the set
|
williamr@4
|
437 |
*
|
williamr@4
|
438 |
* Implements a functionality similar to the DOM NodeList.item().
|
williamr@4
|
439 |
*
|
williamr@4
|
440 |
* Returns the xmlNodePtr at the given index in ns or NULL if
|
williamr@4
|
441 |
* index is out of range (0 to length-1)
|
williamr@4
|
442 |
*/
|
williamr@4
|
443 |
#define xmlXPathNodeSetItem(ns, index) \
|
williamr@4
|
444 |
(( (ns) && ((index) >= 0) && ((index) < (ns)->nodeNr) ) \
|
williamr@4
|
445 |
? (ns)->nodeTab[(index)] \
|
williamr@4
|
446 |
: NULL)
|
williamr@4
|
447 |
/**
|
williamr@4
|
448 |
* xmlXPathNodeSetIsEmpty:
|
williamr@4
|
449 |
* @param ns a node-set
|
williamr@4
|
450 |
*
|
williamr@4
|
451 |
* Checks whether ns is empty or not.
|
williamr@4
|
452 |
*
|
williamr@4
|
453 |
* Returns %TRUE if ns is an empty node-set.
|
williamr@4
|
454 |
*/
|
williamr@4
|
455 |
#define xmlXPathNodeSetIsEmpty(ns) \
|
williamr@4
|
456 |
(((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))
|
williamr@4
|
457 |
|
williamr@4
|
458 |
|
williamr@4
|
459 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
460 |
xmlXPathFreeObject (xmlXPathObjectPtr obj);
|
williamr@4
|
461 |
XMLPUBFUN xmlNodeSetPtr XMLCALL
|
williamr@4
|
462 |
xmlXPathNodeSetCreate (xmlNodePtr val);
|
williamr@4
|
463 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
464 |
xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj);
|
williamr@4
|
465 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
466 |
xmlXPathFreeNodeSet (xmlNodeSetPtr obj);
|
williamr@4
|
467 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
468 |
xmlXPathObjectCopy (xmlXPathObjectPtr val);
|
williamr@4
|
469 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
470 |
xmlXPathCmpNodes (xmlNodePtr node1, xmlNodePtr node2);
|
williamr@4
|
471 |
/**
|
williamr@4
|
472 |
* Conversion functions to basic types.
|
williamr@4
|
473 |
*/
|
williamr@4
|
474 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
475 |
xmlXPathCastNumberToBoolean (double val);
|
williamr@4
|
476 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
477 |
xmlXPathCastStringToBoolean (const xmlChar * val);
|
williamr@4
|
478 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
479 |
xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);
|
williamr@4
|
480 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
481 |
xmlXPathCastToBoolean (xmlXPathObjectPtr val);
|
williamr@4
|
482 |
|
williamr@4
|
483 |
XMLPUBFUN double XMLCALL
|
williamr@4
|
484 |
xmlXPathCastBooleanToNumber (int val);
|
williamr@4
|
485 |
XMLPUBFUN double XMLCALL
|
williamr@4
|
486 |
xmlXPathCastStringToNumber (const xmlChar * val);
|
williamr@4
|
487 |
XMLPUBFUN double XMLCALL
|
williamr@4
|
488 |
xmlXPathCastNodeToNumber (xmlNodePtr node);
|
williamr@4
|
489 |
XMLPUBFUN double XMLCALL
|
williamr@4
|
490 |
xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns);
|
williamr@4
|
491 |
XMLPUBFUN double XMLCALL
|
williamr@4
|
492 |
xmlXPathCastToNumber (xmlXPathObjectPtr val);
|
williamr@4
|
493 |
|
williamr@4
|
494 |
XMLPUBFUN xmlChar* XMLCALL
|
williamr@4
|
495 |
xmlXPathCastBooleanToString (int val);
|
williamr@4
|
496 |
XMLPUBFUN xmlChar* XMLCALL
|
williamr@4
|
497 |
xmlXPathCastNumberToString (double val);
|
williamr@4
|
498 |
XMLPUBFUN xmlChar* XMLCALL
|
williamr@4
|
499 |
xmlXPathCastNodeToString (xmlNodePtr node);
|
williamr@4
|
500 |
XMLPUBFUN xmlChar* XMLCALL
|
williamr@4
|
501 |
xmlXPathCastNodeSetToString (xmlNodeSetPtr ns);
|
williamr@4
|
502 |
XMLPUBFUN xmlChar* XMLCALL
|
williamr@4
|
503 |
xmlXPathCastToString (xmlXPathObjectPtr val);
|
williamr@4
|
504 |
|
williamr@4
|
505 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
506 |
xmlXPathConvertBoolean (xmlXPathObjectPtr val);
|
williamr@4
|
507 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
508 |
xmlXPathConvertNumber (xmlXPathObjectPtr val);
|
williamr@4
|
509 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
510 |
xmlXPathConvertString (xmlXPathObjectPtr val);
|
williamr@4
|
511 |
|
williamr@4
|
512 |
/**
|
williamr@4
|
513 |
* Context handling.
|
williamr@4
|
514 |
*/
|
williamr@4
|
515 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
516 |
xmlXPathInit (void);
|
williamr@4
|
517 |
XMLPUBFUN xmlXPathContextPtr XMLCALL
|
williamr@4
|
518 |
xmlXPathNewContext (xmlDocPtr doc);
|
williamr@4
|
519 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
520 |
xmlXPathFreeContext (xmlXPathContextPtr ctxt);
|
williamr@4
|
521 |
|
williamr@4
|
522 |
/**
|
williamr@4
|
523 |
* Evaluation functions.
|
williamr@4
|
524 |
*/
|
williamr@4
|
525 |
XMLPUBFUN long XMLCALL
|
williamr@4
|
526 |
xmlXPathOrderDocElems (xmlDocPtr doc);
|
williamr@4
|
527 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
528 |
xmlXPathEval (const xmlChar *str, xmlXPathContextPtr ctx);
|
williamr@4
|
529 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
530 |
xmlXPathEvalExpression (const xmlChar *str, xmlXPathContextPtr ctxt);
|
williamr@4
|
531 |
XMLPUBFUN int XMLCALL
|
williamr@4
|
532 |
xmlXPathEvalPredicate (xmlXPathContextPtr ctxt, xmlXPathObjectPtr res);
|
williamr@4
|
533 |
/**
|
williamr@4
|
534 |
* Separate compilation/evaluation entry points.
|
williamr@4
|
535 |
*/
|
williamr@4
|
536 |
XMLPUBFUN xmlXPathCompExprPtr XMLCALL
|
williamr@4
|
537 |
xmlXPathCompile (const xmlChar *str);
|
williamr@4
|
538 |
XMLPUBFUN xmlXPathCompExprPtr XMLCALL
|
williamr@4
|
539 |
xmlXPathCtxtCompile (xmlXPathContextPtr ctxt, const xmlChar *str);
|
williamr@4
|
540 |
XMLPUBFUN xmlXPathObjectPtr XMLCALL
|
williamr@4
|
541 |
xmlXPathCompiledEval (xmlXPathCompExprPtr comp,xmlXPathContextPtr ctx);
|
williamr@4
|
542 |
XMLPUBFUN void XMLCALL
|
williamr@4
|
543 |
xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp);
|
williamr@4
|
544 |
|
williamr@4
|
545 |
#ifdef __cplusplus
|
williamr@4
|
546 |
}
|
williamr@4
|
547 |
#endif
|
williamr@4
|
548 |
|
williamr@4
|
549 |
#endif /* XML_XPATH_H */
|
williamr@4
|
550 |
|