Annotation of XML/xpath.h, revision 1.7

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 !!!! */
                     65:     void *namespaces; /* TODO !!!! */
                     66: } xmlXPathContext, *xmlXPathContextPtr;
                     67: 
                     68: /*
                     69:  * An XPath parser context, it contains pure parsing informations,
                     70:  * an xmlXPathContext, and the stack of objects.
                     71:  */
                     72: typedef struct xmlXPathParserContext {
                     73:     const CHAR *cur;                   /* the current char being parsed */
                     74:     const CHAR *base;                  /* the full expression */
                     75: 
                     76:     int error;                         /* error code */
                     77: 
                     78:     xmlXPathContextPtr  context;       /* the evaluation context */
                     79:     xmlXPathObjectPtr     value;       /* the current value */
                     80:     int                 valueNr;       /* number of values stacked */
                     81:     int                valueMax;       /* max number of values stacked */
                     82:     xmlXPathObjectPtr *valueTab;       /* stack of values */
                     83: } xmlXPathParserContext, *xmlXPathParserContextPtr;
                     84: 
                     85: /*
                     86:  * An XPath function
                     87:  * The arguments (if any) are popped out of the context stack
                     88:  * and the result is pushed on the stack.
                     89:  */
                     90: 
1.4       daniel     91: typedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);
1.1       daniel     92: 
                     93: /************************************************************************
                     94:  *                                                                     *
                     95:  *                     Public API                                      *
                     96:  *                                                                     *
                     97:  ************************************************************************/
                     98: 
1.2       daniel     99: xmlXPathContextPtr xmlXPathNewContext(xmlDocPtr doc, void *variables,
                    100:                                       void *functions, void *namespaces);
1.1       daniel    101: void xmlXPathFreeContext(xmlXPathContextPtr ctxt);
1.3       daniel    102: xmlXPathObjectPtr xmlXPathEval(const CHAR *str, xmlXPathContextPtr ctxt);
                    103: void xmlXPathFreeObject(xmlXPathObjectPtr obj);
1.5       daniel    104: xmlXPathObjectPtr xmlXPathEvalExpression(const CHAR *str,
                    105:                                          xmlXPathContextPtr ctxt);
1.3       daniel    106: 
1.1       daniel    107: #endif /* ! __XML_XPATH_H__ */

Webmaster