xpath.pxd
1 from lxml.includes cimport tree 2 from lxml.includes cimport xmlerror 3 4 from libc.string cimport const_char 5 from lxml.includes.tree cimport xmlChar, const_xmlChar 6 7 cdef extern from "libxml/xpath.h": 8 ctypedef enum xmlXPathObjectType: 9 XPATH_UNDEFINED = 0 10 XPATH_NODESET = 1 11 XPATH_BOOLEAN = 2 12 XPATH_NUMBER = 3 13 XPATH_STRING = 4 14 XPATH_POINT = 5 15 XPATH_RANGE = 6 16 XPATH_LOCATIONSET = 7 17 XPATH_USERS = 8 18 XPATH_XSLT_TREE = 9 19 20 ctypedef enum xmlXPathError: 21 XPATH_EXPRESSION_OK = 0 22 XPATH_NUMBER_ERROR = 1 23 XPATH_UNFINISHED_LITERAL_ERROR = 2 24 XPATH_START_LITERAL_ERROR = 3 25 XPATH_VARIABLE_REF_ERROR = 4 26 XPATH_UNDEF_VARIABLE_ERROR = 5 27 XPATH_INVALID_PREDICATE_ERROR = 6 28 XPATH_EXPR_ERROR = 7 29 XPATH_UNCLOSED_ERROR = 8 30 XPATH_UNKNOWN_FUNC_ERROR = 9 31 XPATH_INVALID_OPERAND = 10 32 XPATH_INVALID_TYPE = 11 33 XPATH_INVALID_ARITY = 12 34 XPATH_INVALID_CTXT_SIZE = 13 35 XPATH_INVALID_CTXT_POSITION = 14 36 XPATH_MEMORY_ERROR = 15 37 XPTR_SYNTAX_ERROR = 16 38 XPTR_RESOURCE_ERROR = 17 39 XPTR_SUB_RESOURCE_ERROR = 18 40 XPATH_UNDEF_PREFIX_ERROR = 19 41 XPATH_ENCODING_ERROR = 20 42 XPATH_INVALID_CHAR_ERROR = 21 43 XPATH_INVALID_CTXT = 22 44 45 ctypedef struct xmlNodeSet: 46 int nodeNr 47 int nodeMax 48 tree.xmlNode** nodeTab 49 50 ctypedef struct xmlXPathObject: 51 xmlXPathObjectType type 52 xmlNodeSet* nodesetval 53 bint boolval 54 double floatval 55 xmlChar* stringval 56 57 ctypedef struct xmlXPathContext: 58 tree.xmlDoc* doc 59 tree.xmlNode* node 60 tree.xmlDict* dict 61 tree.xmlHashTable* nsHash 62 const_xmlChar* function 63 const_xmlChar* functionURI 64 xmlerror.xmlStructuredErrorFunc error 65 xmlerror.xmlError lastError 66 void* userData 67 68 ctypedef struct xmlXPathParserContext: 69 xmlXPathContext* context 70 xmlXPathObject* value 71 tree.xmlNode* ancestor 72 int error 73 74 ctypedef struct xmlXPathCompExpr 75 76 ctypedef void (*xmlXPathFunction)(xmlXPathParserContext* ctxt, int nargs) nogil 77 ctypedef xmlXPathFunction (*xmlXPathFuncLookupFunc)(void* ctxt, 78 const_xmlChar* name, 79 const_xmlChar* ns_uri) nogil 80 81 cdef xmlXPathContext* xmlXPathNewContext(tree.xmlDoc* doc) nogil 82 cdef xmlXPathObject* xmlXPathEvalExpression(const_xmlChar* str, 83 xmlXPathContext* ctxt) nogil 84 cdef xmlXPathObject* xmlXPathCompiledEval(xmlXPathCompExpr* comp, 85 xmlXPathContext* ctxt) nogil 86 cdef xmlXPathCompExpr* xmlXPathCompile(const_xmlChar* str) nogil 87 cdef xmlXPathCompExpr* xmlXPathCtxtCompile(xmlXPathContext* ctxt, 88 const_xmlChar* str) nogil 89 cdef void xmlXPathFreeContext(xmlXPathContext* ctxt) nogil 90 cdef void xmlXPathFreeCompExpr(xmlXPathCompExpr* comp) nogil 91 cdef void xmlXPathFreeObject(xmlXPathObject* obj) nogil 92 cdef int xmlXPathRegisterNs(xmlXPathContext* ctxt, 93 const_xmlChar* prefix, const_xmlChar* ns_uri) nogil 94 95 cdef xmlNodeSet* xmlXPathNodeSetCreate(tree.xmlNode* val) nogil 96 cdef void xmlXPathFreeNodeSet(xmlNodeSet* val) nogil 97 98 99 cdef extern from "libxml/xpathInternals.h": 100 cdef int xmlXPathRegisterFunc(xmlXPathContext* ctxt, 101 const_xmlChar* name, 102 xmlXPathFunction f) nogil 103 cdef int xmlXPathRegisterFuncNS(xmlXPathContext* ctxt, 104 const_xmlChar* name, 105 const_xmlChar* ns_uri, 106 xmlXPathFunction f) nogil 107 cdef void xmlXPathRegisterFuncLookup(xmlXPathContext *ctxt, 108 xmlXPathFuncLookupFunc f, 109 void *funcCtxt) nogil 110 cdef int xmlXPathRegisterVariable(xmlXPathContext *ctxt, 111 const_xmlChar* name, 112 xmlXPathObject* value) nogil 113 cdef int xmlXPathRegisterVariableNS(xmlXPathContext *ctxt, 114 const_xmlChar* name, 115 const_xmlChar* ns_uri, 116 xmlXPathObject* value) nogil 117 cdef void xmlXPathRegisteredVariablesCleanup(xmlXPathContext *ctxt) nogil 118 cdef void xmlXPathRegisteredNsCleanup(xmlXPathContext *ctxt) nogil 119 cdef xmlXPathObject* valuePop (xmlXPathParserContext *ctxt) nogil 120 cdef int valuePush(xmlXPathParserContext* ctxt, xmlXPathObject *value) nogil 121 122 cdef xmlXPathObject* xmlXPathNewCString(const_char *val) nogil 123 cdef xmlXPathObject* xmlXPathWrapCString(const_char * val) nogil 124 cdef xmlXPathObject* xmlXPathNewString(const_xmlChar *val) nogil 125 cdef xmlXPathObject* xmlXPathWrapString(const_xmlChar * val) nogil 126 cdef xmlXPathObject* xmlXPathNewFloat(double val) nogil 127 cdef xmlXPathObject* xmlXPathNewBoolean(int val) nogil 128 cdef xmlXPathObject* xmlXPathNewNodeSet(tree.xmlNode* val) nogil 129 cdef xmlXPathObject* xmlXPathNewValueTree(tree.xmlNode* val) nogil 130 cdef void xmlXPathNodeSetAdd(xmlNodeSet* cur, 131 tree.xmlNode* val) nogil 132 cdef void xmlXPathNodeSetAddUnique(xmlNodeSet* cur, 133 tree.xmlNode* val) nogil 134 cdef xmlXPathObject* xmlXPathWrapNodeSet(xmlNodeSet* val) nogil 135 cdef void xmlXPathErr(xmlXPathParserContext* ctxt, int error) nogil