Annotation of XML/xpath.h, revision 1.8
1.1 daniel 1: /*
2: * xpath.c: interface for XML Path Language implementation
3: *
4: * Reference: W3C Working Draft 5 July 1999
5: * http://www.w3.org/Style/XSL/Group/1999/07/xpath-19990705.html
6: *
7: * See COPYRIGHT for the status of this software
8: *
9: * Author: Daniel.Veillard@w3.org
10: */
11:
12: #ifndef __XML_XPATH_H__
13: #define __XML_XPATH_H__
14:
15: #include "tree.h"
16:
17: /*
18: * A node-set (an unordered collection of nodes without duplicates)
19: */
20: typedef struct xmlNodeSet {
21: int nodeNr; /* # of node in the set */
22: int nodeMax; /* allocated space */
23: xmlNodePtr *nodeTab; /* array of nodes in no particular order */
24: } xmlNodeSet, *xmlNodeSetPtr;
25:
26: /*
27: * An expression is evaluated to yield an object, which
28: * has one of the following four basic types:
29: * - node-set
30: * - boolean
31: * - number
32: * - string
33: */
34:
35: #define XPATH_UNDEFINED 0
36: #define XPATH_NODESET 1
37: #define XPATH_BOOLEAN 2
38: #define XPATH_NUMBER 3
39: #define XPATH_STRING 4
40:
41: typedef struct xmlXPathObject {
42: int type;
43: xmlNodeSetPtr nodesetval;
44: int boolval;
1.6 daniel 45: double floatval;
1.1 daniel 46: CHAR *stringval;
47: } xmlXPathObject, *xmlXPathObjectPtr;
48:
49: /*
50: * Expression evaluation occurs with respect to a context.
51: * he context consists of:
52: * - a node (the context node)
53: * - a node list (the context node list)
54: * - a set of variable bindings
55: * - a function library
56: * - the set of namespace declarations in scope for the expression
57: */
58:
59: typedef struct xmlXPathContext {
1.2 daniel 60: xmlDocPtr doc; /* The current document */
61: xmlNodePtr node; /* The current node */
62: xmlNodeSetPtr nodelist; /* The current node list */
1.1 daniel 63: void *variables; /* TODO !!!! */
64: void *functions; /* TODO !!!! */
1.8 ! daniel 65: xmlNsPtr *namespaces; /* The namespaces lookup */
! 66: int nsNr; /* the current Namespace index */
1.1 daniel 67: } xmlXPathContext, *xmlXPathContextPtr;
68:
69: /*
70: * An XPath parser context, it contains pure parsing informations,
71: * an xmlXPathContext, and the stack of objects.
72: */
73: typedef struct xmlXPathParserContext {
74: const CHAR *cur; /* the current char being parsed */
75: const CHAR *base; /* the full expression */
76:
77: int error; /* error code */
78:
79: xmlXPathContextPtr context; /* the evaluation context */
80: xmlXPathObjectPtr value; /* the current value */
81: int valueNr; /* number of values stacked */
82: int valueMax; /* max number of values stacked */
83: xmlXPathObjectPtr *valueTab; /* stack of values */
84: } xmlXPathParserContext, *xmlXPathParserContextPtr;
85:
86: /*
87: * An XPath function
88: * The arguments (if any) are popped out of the context stack
89: * and the result is pushed on the stack.
90: */
91:
1.4 daniel 92: typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
1.1 daniel 93:
94: /************************************************************************
95: * *
96: * Public API *
97: * *
98: ************************************************************************/
99:
1.8 ! daniel 100: xmlXPathContextPtr xmlXPathNewContext (xmlDocPtr doc,
! 101: void *variables,
! 102: void *functions);
! 103: void xmlXPathFreeContext (xmlXPathContextPtr ctxt);
! 104: xmlXPathObjectPtr xmlXPathEval (const CHAR *str,
! 105: xmlXPathContextPtr ctxt);
! 106: void xmlXPathFreeObject (xmlXPathObjectPtr obj);
! 107: xmlXPathObjectPtr xmlXPathEvalExpression (const CHAR *str,
! 108: xmlXPathContextPtr ctxt);
1.3 daniel 109:
1.1 daniel 110: #endif /* ! __XML_XPATH_H__ */
Webmaster