ReactOS 0.4.16-dev-2207-geb15453
xpathInternals.h
Go to the documentation of this file.
1/*
2 * 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
6 *
7 * Copy: See Copyright for the status of this software.
8 *
9 * Author: Daniel Veillard
10 */
11
12#ifndef __XML_XPATH_INTERNALS_H__
13#define __XML_XPATH_INTERNALS_H__
14
15#include <stdio.h>
16#include <libxml/xmlversion.h>
17#include <libxml/xpath.h>
18
19#ifdef LIBXML_XPATH_ENABLED
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/************************************************************************
26 * *
27 * Helpers *
28 * *
29 ************************************************************************/
30
31/*
32 * Many of these macros may later turn into functions. They
33 * shouldn't be used in #ifdef's preprocessor instructions.
34 */
42#define xmlXPathSetError(ctxt, err) \
43 { xmlXPatherror((ctxt), __FILE__, __LINE__, (err)); \
44 if ((ctxt) != NULL) (ctxt)->error = (err); }
45
52#define xmlXPathSetArityError(ctxt) \
53 xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)
54
61#define xmlXPathSetTypeError(ctxt) \
62 xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)
63
72#define xmlXPathGetError(ctxt) ((ctxt)->error)
73
82#define xmlXPathCheckError(ctxt) ((ctxt)->error != XPATH_EXPRESSION_OK)
83
92#define xmlXPathGetDocument(ctxt) ((ctxt)->context->doc)
93
102#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node)
103
104XMLPUBFUN int
105 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
106XMLPUBFUN double
107 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
109 xmlXPathPopString (xmlXPathParserContextPtr ctxt);
110XMLPUBFUN xmlNodeSetPtr
111 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
112XMLPUBFUN void *
113 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
114
122#define xmlXPathReturnBoolean(ctxt, val) \
123 valuePush((ctxt), xmlXPathNewBoolean(val))
124
131#define xmlXPathReturnTrue(ctxt) xmlXPathReturnBoolean((ctxt), 1)
132
139#define xmlXPathReturnFalse(ctxt) xmlXPathReturnBoolean((ctxt), 0)
140
148#define xmlXPathReturnNumber(ctxt, val) \
149 valuePush((ctxt), xmlXPathNewFloat(val))
150
158#define xmlXPathReturnString(ctxt, str) \
159 valuePush((ctxt), xmlXPathWrapString(str))
160
167#define xmlXPathReturnEmptyString(ctxt) \
168 valuePush((ctxt), xmlXPathNewCString(""))
169
177#define xmlXPathReturnNodeSet(ctxt, ns) \
178 valuePush((ctxt), xmlXPathWrapNodeSet(ns))
179
186#define xmlXPathReturnEmptyNodeSet(ctxt) \
187 valuePush((ctxt), xmlXPathNewNodeSet(NULL))
188
196#define xmlXPathReturnExternal(ctxt, val) \
197 valuePush((ctxt), xmlXPathWrapExternal(val))
198
208#define xmlXPathStackIsNodeSet(ctxt) \
209 (((ctxt)->value != NULL) \
210 && (((ctxt)->value->type == XPATH_NODESET) \
211 || ((ctxt)->value->type == XPATH_XSLT_TREE)))
212
223#define xmlXPathStackIsExternal(ctxt) \
224 ((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))
225
232#define xmlXPathEmptyNodeSet(ns) \
233 { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; }
234
240#define CHECK_ERROR \
241 if (ctxt->error != XPATH_EXPRESSION_OK) return
242
248#define CHECK_ERROR0 \
249 if (ctxt->error != XPATH_EXPRESSION_OK) return(0)
250
257#define XP_ERROR(X) \
258 { xmlXPathErr(ctxt, X); return; }
259
266#define XP_ERROR0(X) \
267 { xmlXPathErr(ctxt, X); return(0); }
268
276#define CHECK_TYPE(typeval) \
277 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
278 XP_ERROR(XPATH_INVALID_TYPE)
279
287#define CHECK_TYPE0(typeval) \
288 if ((ctxt->value == NULL) || (ctxt->value->type != typeval)) \
289 XP_ERROR0(XPATH_INVALID_TYPE)
290
297#define CHECK_ARITY(x) \
298 if (ctxt == NULL) return; \
299 if (nargs != (x)) \
300 XP_ERROR(XPATH_INVALID_ARITY); \
301 if (ctxt->valueNr < (x)) \
302 XP_ERROR(XPATH_STACK_ERROR);
303
309#define CAST_TO_STRING \
310 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING)) \
311 xmlXPathStringFunction(ctxt, 1);
312
318#define CAST_TO_NUMBER \
319 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER)) \
320 xmlXPathNumberFunction(ctxt, 1);
321
327#define CAST_TO_BOOLEAN \
328 if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN)) \
329 xmlXPathBooleanFunction(ctxt, 1);
330
331/*
332 * Variable Lookup forwarding.
333 */
334
335XMLPUBFUN void
336 xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
337 xmlXPathVariableLookupFunc f,
338 void *data);
339
340/*
341 * Function Lookup forwarding.
342 */
343
344XMLPUBFUN void
345 xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
346 xmlXPathFuncLookupFunc f,
347 void *funcCtxt);
348
349/*
350 * Error reporting.
351 */
352XMLPUBFUN void
353 xmlXPatherror (xmlXPathParserContextPtr ctxt,
354 const char *file,
355 int line,
356 int no);
357
358XMLPUBFUN void
359 xmlXPathErr (xmlXPathParserContextPtr ctxt,
360 int error);
361
362#ifdef LIBXML_DEBUG_ENABLED
363XMLPUBFUN void
364 xmlXPathDebugDumpObject (FILE *output,
365 xmlXPathObjectPtr cur,
366 int depth);
367XMLPUBFUN void
368 xmlXPathDebugDumpCompExpr(FILE *output,
369 xmlXPathCompExprPtr comp,
370 int depth);
371#endif
375XMLPUBFUN int
376 xmlXPathNodeSetContains (xmlNodeSetPtr cur,
377 xmlNodePtr val);
378XMLPUBFUN xmlNodeSetPtr
379 xmlXPathDifference (xmlNodeSetPtr nodes1,
380 xmlNodeSetPtr nodes2);
381XMLPUBFUN xmlNodeSetPtr
382 xmlXPathIntersection (xmlNodeSetPtr nodes1,
383 xmlNodeSetPtr nodes2);
384
385XMLPUBFUN xmlNodeSetPtr
386 xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
387XMLPUBFUN xmlNodeSetPtr
388 xmlXPathDistinct (xmlNodeSetPtr nodes);
389
390XMLPUBFUN int
391 xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
392 xmlNodeSetPtr nodes2);
393
394XMLPUBFUN xmlNodeSetPtr
395 xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
396 xmlNodePtr node);
397XMLPUBFUN xmlNodeSetPtr
398 xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
399 xmlNodeSetPtr nodes2);
400XMLPUBFUN xmlNodeSetPtr
401 xmlXPathNodeLeading (xmlNodeSetPtr nodes,
402 xmlNodePtr node);
403XMLPUBFUN xmlNodeSetPtr
404 xmlXPathLeading (xmlNodeSetPtr nodes1,
405 xmlNodeSetPtr nodes2);
406
407XMLPUBFUN xmlNodeSetPtr
408 xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
409 xmlNodePtr node);
410XMLPUBFUN xmlNodeSetPtr
411 xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
412 xmlNodeSetPtr nodes2);
413XMLPUBFUN xmlNodeSetPtr
414 xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
415 xmlNodePtr node);
416XMLPUBFUN xmlNodeSetPtr
417 xmlXPathTrailing (xmlNodeSetPtr nodes1,
418 xmlNodeSetPtr nodes2);
419
420
425XMLPUBFUN int
426 xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
427 const xmlChar *prefix,
428 const xmlChar *ns_uri);
429XMLPUBFUN const xmlChar *
430 xmlXPathNsLookup (xmlXPathContextPtr ctxt,
431 const xmlChar *prefix);
432XMLPUBFUN void
433 xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
434
435XMLPUBFUN int
436 xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
437 const xmlChar *name,
438 xmlXPathFunction f);
439XMLPUBFUN int
440 xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
441 const xmlChar *name,
442 const xmlChar *ns_uri,
443 xmlXPathFunction f);
444XMLPUBFUN int
445 xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
446 const xmlChar *name,
447 xmlXPathObjectPtr value);
448XMLPUBFUN int
449 xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
450 const xmlChar *name,
451 const xmlChar *ns_uri,
452 xmlXPathObjectPtr value);
453XMLPUBFUN xmlXPathFunction
454 xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
455 const xmlChar *name);
456XMLPUBFUN xmlXPathFunction
457 xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
458 const xmlChar *name,
459 const xmlChar *ns_uri);
460XMLPUBFUN void
461 xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt);
462XMLPUBFUN xmlXPathObjectPtr
463 xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
464 const xmlChar *name);
465XMLPUBFUN xmlXPathObjectPtr
466 xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
467 const xmlChar *name,
468 const xmlChar *ns_uri);
469XMLPUBFUN void
470 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
471
475XMLPUBFUN xmlXPathParserContextPtr
476 xmlXPathNewParserContext (const xmlChar *str,
477 xmlXPathContextPtr ctxt);
478XMLPUBFUN void
479 xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
480
481/* TODO: remap to xmlXPathValuePop and Push. */
482XMLPUBFUN xmlXPathObjectPtr
483 valuePop (xmlXPathParserContextPtr ctxt);
484XMLPUBFUN int
485 valuePush (xmlXPathParserContextPtr ctxt,
486 xmlXPathObjectPtr value);
487
488XMLPUBFUN xmlXPathObjectPtr
489 xmlXPathNewString (const xmlChar *val);
490XMLPUBFUN xmlXPathObjectPtr
491 xmlXPathNewCString (const char *val);
492XMLPUBFUN xmlXPathObjectPtr
493 xmlXPathWrapString (xmlChar *val);
494XMLPUBFUN xmlXPathObjectPtr
495 xmlXPathWrapCString (char * val);
496XMLPUBFUN xmlXPathObjectPtr
497 xmlXPathNewFloat (double val);
498XMLPUBFUN xmlXPathObjectPtr
499 xmlXPathNewBoolean (int val);
500XMLPUBFUN xmlXPathObjectPtr
501 xmlXPathNewNodeSet (xmlNodePtr val);
502XMLPUBFUN xmlXPathObjectPtr
503 xmlXPathNewValueTree (xmlNodePtr val);
504XMLPUBFUN int
505 xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
506 xmlNodePtr val);
507XMLPUBFUN int
508 xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
509 xmlNodePtr val);
510XMLPUBFUN int
511 xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
512 xmlNodePtr node,
513 xmlNsPtr ns);
514XMLPUBFUN void
515 xmlXPathNodeSetSort (xmlNodeSetPtr set);
516
517XMLPUBFUN void
518 xmlXPathRoot (xmlXPathParserContextPtr ctxt);
519XMLPUBFUN void
520 xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
522 xmlXPathParseName (xmlXPathParserContextPtr ctxt);
524 xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
525
526/*
527 * Existing functions.
528 */
529XMLPUBFUN double
530 xmlXPathStringEvalNumber (const xmlChar *str);
531XMLPUBFUN int
532 xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
533 xmlXPathObjectPtr res);
534XMLPUBFUN void
535 xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt);
536XMLPUBFUN xmlNodeSetPtr
537 xmlXPathNodeSetMerge (xmlNodeSetPtr val1,
538 xmlNodeSetPtr val2);
539XMLPUBFUN void
540 xmlXPathNodeSetDel (xmlNodeSetPtr cur,
541 xmlNodePtr val);
542XMLPUBFUN void
543 xmlXPathNodeSetRemove (xmlNodeSetPtr cur,
544 int val);
545XMLPUBFUN xmlXPathObjectPtr
546 xmlXPathNewNodeSetList (xmlNodeSetPtr val);
547XMLPUBFUN xmlXPathObjectPtr
548 xmlXPathWrapNodeSet (xmlNodeSetPtr val);
549XMLPUBFUN xmlXPathObjectPtr
550 xmlXPathWrapExternal (void *val);
551
552XMLPUBFUN int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
553XMLPUBFUN int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);
554XMLPUBFUN int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);
555XMLPUBFUN void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);
556XMLPUBFUN void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);
557XMLPUBFUN void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);
558XMLPUBFUN void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);
559XMLPUBFUN void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);
560XMLPUBFUN void xmlXPathModValues(xmlXPathParserContextPtr ctxt);
561
562XMLPUBFUN int xmlXPathIsNodeType(const xmlChar *name);
563
564/*
565 * Some of the axis navigation routines.
566 */
567XMLPUBFUN xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,
568 xmlNodePtr cur);
569XMLPUBFUN xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,
570 xmlNodePtr cur);
571XMLPUBFUN xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,
572 xmlNodePtr cur);
573XMLPUBFUN xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,
574 xmlNodePtr cur);
575XMLPUBFUN xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,
576 xmlNodePtr cur);
577XMLPUBFUN xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,
578 xmlNodePtr cur);
579XMLPUBFUN xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,
580 xmlNodePtr cur);
581XMLPUBFUN xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,
582 xmlNodePtr cur);
583XMLPUBFUN xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,
584 xmlNodePtr cur);
585XMLPUBFUN xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,
586 xmlNodePtr cur);
587XMLPUBFUN xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,
588 xmlNodePtr cur);
589XMLPUBFUN xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,
590 xmlNodePtr cur);
591XMLPUBFUN xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,
592 xmlNodePtr cur);
593/*
594 * The official core of XPath functions.
595 */
596XMLPUBFUN void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);
597XMLPUBFUN void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);
598XMLPUBFUN void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);
599XMLPUBFUN void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);
600XMLPUBFUN void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);
601XMLPUBFUN void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);
602XMLPUBFUN void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);
603XMLPUBFUN void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);
604XMLPUBFUN void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);
605XMLPUBFUN void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);
606XMLPUBFUN void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);
607XMLPUBFUN void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);
608XMLPUBFUN void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);
609XMLPUBFUN void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);
610XMLPUBFUN void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);
611XMLPUBFUN void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);
612XMLPUBFUN void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);
613XMLPUBFUN void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);
614XMLPUBFUN void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);
615XMLPUBFUN void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);
616XMLPUBFUN void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);
617XMLPUBFUN void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);
618XMLPUBFUN void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);
619XMLPUBFUN void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);
620XMLPUBFUN void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);
621XMLPUBFUN void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);
622
626XMLPUBFUN void xmlXPathNodeSetFreeNs(xmlNsPtr ns);
627
628#ifdef __cplusplus
629}
630#endif
631
632#endif /* LIBXML_XPATH_ENABLED */
633#endif /* ! __XML_XPATH_INTERNALS_H__ */
Definition: _set.h:50
static WCHAR no[MAX_STRING_RESOURCE_LEN]
Definition: object.c:2340
FxCollectionEntry * cur
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLuint res
Definition: glext.h:9613
GLfloat f
Definition: glext.h:7540
GLuint GLfloat * val
Definition: glext.h:7180
#define error(str)
Definition: mkdosfs.c:1605
static int strict
Definition: error.c:51
const WCHAR * str
Definition: fci.c:127
Definition: parser.c:49
Definition: name.c:39
Definition: mxnamespace.c:38
Character const *const prefix
Definition: tempnam.cpp:195
Definition: dlist.c:348
Definition: pdh_main.c:96
#define XMLPUBFUN
Definition: xmlexports.h:30
unsigned char xmlChar
Definition: xmlstring.h:28