Annotation of XML/xpath.h, revision 1.6

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
1.4       daniel     40: #define XPATH_MARKER   5  /* used for func call checks */
1.1       daniel     41: 
                     42: typedef struct xmlXPathObject {
                     43:     int type;
                     44:     xmlNodeSetPtr nodesetval;
                     45:     int boolval;
1.6     ! daniel     46:     double floatval;
1.1       daniel     47:     CHAR *stringval;
                     48: } xmlXPathObject, *xmlXPathObjectPtr;
                     49: 
                     50: /* 
                     51:  * Expression evaluation occurs with respect to a context.
                     52:  * he context consists of:
                     53:  *    - a node (the context node) 
                     54:  *    - a node list (the context node list) 
                     55:  *    - a set of variable bindings 
                     56:  *    - a function library 
                     57:  *    - the set of namespace declarations in scope for the expression 
                     58:  */
                     59: 
                     60: typedef struct xmlXPathContext {
1.2       daniel     61:     xmlDocPtr doc;                     /* The current document */
                     62:     xmlNodePtr node;                   /* The current node */
                     63:     xmlNodeSetPtr nodelist;            /* The current node list */
1.1       daniel     64:     void *variables; /* TODO !!!! */
                     65:     void *functions; /* TODO !!!! */
                     66:     void *namespaces; /* TODO !!!! */
                     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.2       daniel    100: xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc, void *variables,
                    101:                                       void *functions, void *namespaces);
1.1       daniel    102: void xmlXPathFreeContext(xmlXPathContextPtr ctxt);
1.3       daniel    103: xmlXPathObjectPtr xmlXPathEval(const CHAR *str, xmlXPathContextPtr ctxt);
                    104: void xmlXPathFreeObject(xmlXPathObjectPtr obj);
1.5       daniel    105: xmlXPathObjectPtr xmlXPathEvalExpression(const CHAR *str,
                    106:                                          xmlXPathContextPtr ctxt);
1.3       daniel    107: 
1.1       daniel    108: #endif /* ! __XML_XPATH_H__ */

Webmaster