xpath.inc 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. (*
  2. * Summary: XML Path Language implementation
  3. * Description: API for the XML Path Language implementation
  4. *
  5. * XML Path Language implementation
  6. * XPath is a language for addressing parts of an XML document,
  7. * designed to be used by both XSLT and XPointer
  8. * http://www.w3.org/TR/xpath
  9. *
  10. * Implements
  11. * W3C Recommendation 16 November 1999
  12. * http://www.w3.org/TR/1999/REC-xpath-19991116
  13. *
  14. * Copy: See Copyright for the status of this software.
  15. *
  16. * Author: Daniel Veillard
  17. *)
  18. {$IFDEF LIBXML_XPATH_ENABLED}
  19. {$IFDEF POINTER}
  20. xmlXPathContextPtr = ^xmlXPathContext;
  21. xmlXPathParserContextPtr = ^xmlXPathParserContext;
  22. xmlNodeSetPtr = ^xmlNodeSet;
  23. xmlXPathObjectPtr = ^xmlXPathObject;
  24. xmlXPathObjectPtrPtr = ^xmlXPathObjectPtr;
  25. xmlXPathTypePtr = ^xmlXPathType;
  26. xmlXPathVariablePtr = ^xmlXPathVariable;
  27. xmlXPathFuncPtr = ^xmlXPathFunc;
  28. xmlXPathAxisPtr = ^xmlXPathAxis;
  29. xmlXPathCompExprPtr = ^xmlXPathCompExpr;
  30. {$ENDIF}
  31. {$IFDEF TYPE}
  32. (**
  33. * The set of XPath error codes.
  34. *)
  35. xmlXPathError = (
  36. XPATH_EXPRESSION_OK = 0,
  37. XPATH_NUMBER_ERROR,
  38. XPATH_UNFINISHED_LITERAL_ERROR,
  39. XPATH_START_LITERAL_ERROR,
  40. XPATH_VARIABLE_REF_ERROR,
  41. XPATH_UNDEF_VARIABLE_ERROR,
  42. XPATH_INVALID_PREDICATE_ERROR,
  43. XPATH_EXPR_ERROR,
  44. XPATH_UNCLOSED_ERROR,
  45. XPATH_UNKNOWN_FUNC_ERROR,
  46. XPATH_INVALID_OPERAND,
  47. XPATH_INVALID_TYPE,
  48. XPATH_INVALID_ARITY,
  49. XPATH_INVALID_CTXT_SIZE,
  50. XPATH_INVALID_CTXT_POSITION,
  51. XPATH_MEMORY_ERROR,
  52. XPTR_SYNTAX_ERROR,
  53. XPTR_RESOURCE_ERROR,
  54. XPTR_SUB_RESOURCE_ERROR,
  55. XPATH_UNDEF_PREFIX_ERROR,
  56. XPATH_ENCODING_ERROR,
  57. XPATH_INVALID_CHAR_ERROR,
  58. XPATH_INVALID_CTXT,
  59. XPATH_STACK_ERROR,
  60. XPATH_FORBID_VARIABLE_ERROR,
  61. XPATH_OP_LIMIT_EXCEEDED,
  62. XPATH_RECURSION_LIMIT_EXCEEDED
  63. );
  64. (*
  65. * A node-set (an unordered collection of nodes without duplicates).
  66. *)
  67. xmlNodeSet = record
  68. nodeNr : cint; (* number of nodes in the set *)
  69. nodeMax : cint; (* size of the array as allocated *)
  70. nodeTab : xmlNodePtrPtr; (* array of nodes in no particular order *)
  71. (* @@ with_ns to check wether namespace nodes should be looked at @@ *)
  72. end;
  73. (*
  74. * An expression is evaluated to yield an object, which
  75. * has one of the following four basic types:
  76. * - node-set
  77. * - boolean
  78. * - number
  79. * - string
  80. *
  81. * @@ XPointer will add more types !
  82. *)
  83. xmlXPathObjectType = (
  84. XPATH_UNDEFINED = 0,
  85. XPATH_NODESET = 1,
  86. XPATH_BOOLEAN = 2,
  87. XPATH_NUMBER = 3,
  88. XPATH_STRING = 4,
  89. XPATH_POINT = 5,
  90. XPATH_RANGE = 6,
  91. XPATH_LOCATIONSET = 7,
  92. XPATH_USERS = 8,
  93. XPATH_XSLT_TREE = 9 (* An XSLT value tree, non modifiable *)
  94. );
  95. xmlXPathObject = record
  96. _type : xmlXPathObjectType;
  97. nodesetval : xmlNodeSetPtr;
  98. boolval : cint;
  99. floatval : cdouble;
  100. stringval : xmlCharPtr;
  101. user : pointer;
  102. index : cint;
  103. user2 : pointer;
  104. index2 : cint;
  105. end;
  106. (**
  107. * xmlXPathConvertFunc:
  108. * @obj: an XPath object
  109. * @type: the number of the target type
  110. *
  111. * A conversion function is associated to a type and used to cast
  112. * the new type to primitive values.
  113. *
  114. * Returns -1 in case of error, 0 otherwise
  115. *)
  116. xmlXPathConvertFunc = function(obj: xmlXPathObjectPtr; _type: cint): cint; EXTDECL;
  117. (*
  118. * Extra type: a name and a conversion function.
  119. *)
  120. xmlXPathType = record
  121. name : xmlCharPtr; (* the type name *)
  122. func : xmlXPathConvertFunc; (* the conversion function *)
  123. end;
  124. (*
  125. * Extra variable: a name and a value.
  126. *)
  127. xmlXPathVariable = record
  128. name : xmlCharPtr; (* the variable name *)
  129. value : xmlXPathObjectPtr; (* the value *)
  130. end;
  131. (**
  132. * xmlXPathEvalFunc:
  133. * @ctxt: an XPath parser context
  134. * @nargs: the number of arguments passed to the function
  135. *
  136. * An XPath evaluation function, the parameters are on the XPath context stack.
  137. *)
  138. xmlXPathEvalFunc = procedure(ctxt: xmlXPathParserContextPtr; nargs: cint); EXTDECL;
  139. (*
  140. * Extra function: a name and a evaluation function.
  141. *)
  142. xmlXPathFunc = record
  143. name : xmlCharPtr; (* the function name *)
  144. func : xmlXPathEvalFunc; (* the evaluation function *)
  145. end;
  146. (**
  147. * xmlXPathAxisFunc:
  148. * @ctxt: the XPath interpreter context
  149. * @cur: the previous node being explored on that axis
  150. *
  151. * An axis traversal function. To traverse an axis, the engine calls
  152. * the first time with cur == NULL and repeat until the function returns
  153. * NULL indicating the end of the axis traversal.
  154. *
  155. * Returns the next node in that axis or NULL if at the end of the axis.
  156. *)
  157. xmlXPathAxisFunc = function(ctxt: xmlXPathParserContextPtr; cur: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL;
  158. (*
  159. * Extra axis: a name and an axis function.
  160. *)
  161. xmlXPathAxis = record
  162. name : xmlCharPtr; (* the axis name *)
  163. func : xmlXPathAxisFunc; (* the search function *)
  164. end;
  165. (**
  166. * xmlXPathFunction:
  167. * @ctxt: the XPath interprestation context
  168. * @nargs: the number of arguments
  169. *
  170. * An XPath function.
  171. * The arguments (if any) are popped out from the context stack
  172. * and the result is pushed on the stack.
  173. *)
  174. xmlXPathFunction = procedure(ctxt: xmlXPathParserContextPtr; nargs: cint); EXTDECL;
  175. (*
  176. * Function and Variable Lookup.
  177. *)
  178. (**
  179. * xmlXPathVariableLookupFunc:
  180. * @ctxt: an XPath context
  181. * @name: name of the variable
  182. * @ns_uri: the namespace name hosting this variable
  183. *
  184. * Prototype for callbacks used to plug variable lookup in the XPath
  185. * engine.
  186. *
  187. * Returns the XPath object value or NULL if not found.
  188. *)
  189. xmlXPathVariableLookupFunc = function(ctxt: pointer; name, ns_uri: xmlCharPtr): xmlXPathObjectPtr; EXTDECL;
  190. (**
  191. * xmlXPathFuncLookupFunc:
  192. * @ctxt: an XPath context
  193. * @name: name of the function
  194. * @ns_uri: the namespace name hosting this function
  195. *
  196. * Prototype for callbacks used to plug function lookup in the XPath
  197. * engine.
  198. *
  199. * Returns the XPath function or NULL if not found.
  200. *)
  201. xmlXPathFuncLookupFunc = function(ctxt: pointer; name, ns_uri: xmlCharPtr): xmlXPathFunction; EXTDECL;
  202. {$ENDIF}
  203. {$IFDEF CONST}
  204. (**
  205. * xmlXPathFlags:
  206. * Flags for XPath engine compilation and runtime
  207. *)
  208. (**
  209. * XML_XPATH_CHECKNS:
  210. *
  211. * check namespaces at compilation
  212. *)
  213. XML_XPATH_CHECKNS = (1 shl 0);
  214. (**
  215. * XML_XPATH_NOVAR:
  216. *
  217. * forbid variables in expression
  218. *)
  219. XML_XPATH_NOVAR = (1 shl 1);
  220. {$ENDIF}
  221. {$IFDEF TYPE}
  222. (**
  223. * xmlXPathContext:
  224. *
  225. * Expression evaluation occurs with respect to a context.
  226. * he context consists of:
  227. * - a node (the context node)
  228. * - a node list (the context node list)
  229. * - a set of variable bindings
  230. * - a function library
  231. * - the set of namespace declarations in scope for the expression
  232. * Following the switch to hash tables, this need to be trimmed up at
  233. * the next binary incompatible release.
  234. * The node may be modified when the context is passed to libxml2
  235. * for an XPath evaluation so you may need to initialize it again
  236. * before the next call.
  237. *)
  238. xmlXPathContext = record
  239. doc : xmlDocPtr; (* The current document *)
  240. node : xmlNodePtr; (* The current node *)
  241. nb_variables_unused : cint; (* unused (hash table) *)
  242. max_variables_unused: cint; (* unused (hash table) *)
  243. varHash : xmlHashTablePtr; (* Hash table of defined variables *)
  244. nb_types : cint; (* number of defined types *)
  245. max_types : cint; (* max number of types *)
  246. types : xmlXPathTypePtr; (* Array of defined types *)
  247. nb_funcs_unused : cint; (* unused (hash table) *)
  248. max_funcs_unused : cint; (* unused (hash table) *)
  249. funcHash : xmlHashTablePtr; (* Hash table of defined funcs *)
  250. nb_axis : cint; (* number of defined axis *)
  251. max_axis : cint; (* max number of axis *)
  252. axis : xmlXPathAxisPtr; (* Array of defined axis *)
  253. (* the namespace nodes of the context node *)
  254. namespaces : xmlNsPtrPtr; (* Array of namespaces *)
  255. nsNr : cint; (* number of namespace in scope *)
  256. user : pointer; (* function to free *)
  257. (* extra variables *)
  258. contextSize : cint; (* the context size *)
  259. proximityPosition : cint; (* the proximity position *)
  260. (* extra stuff for XPointer *)
  261. xptr : cint; (* is this an XPointer context? *)
  262. here : xmlNodePtr; (* for here() *)
  263. origin : xmlNodePtr; (* for origin() *)
  264. (* the set of namespace declarations in scope for the expression *)
  265. nsHash : xmlHashTablePtr; (* The namespaces hash table *)
  266. varLookupFunc : xmlXPathVariableLookupFunc;(* variable lookup func *)
  267. varLookupData : pointer; (* variable lookup data *)
  268. (* Possibility to link in an extra item *)
  269. extra : pointer; (* needed for XSLT *)
  270. (* The function name and URI when calling a function *)
  271. _function : xmlCharPtr;
  272. functionURI : xmlCharPtr;
  273. (* function lookup function and data *)
  274. funcLookupFunc : xmlXPathFuncLookupFunc;(* function lookup func *)
  275. funcLookupData : pointer; (* function lookup data *)
  276. (* temporary namespace lists kept for walking the namespace axis *)
  277. tmpNsList : xmlNsPtr; (* Array of namespaces *)
  278. tmpNsNr : cint; (* number of namespaces in scope *)
  279. (* error reporting mechanism *)
  280. userData : pointer; (* user specific data block *)
  281. error : xmlStructuredErrorFunc; (* the callback in case of errors *)
  282. lastError : xmlError; (* the last error *)
  283. debugNode : xmlNodePtr; (* the source node XSLT *)
  284. (* dictionary *)
  285. dict : xmlDictPtr; (* dictionary if any *)
  286. flags : cint; (* flags to control compilation *)
  287. (* Cache for reusal of XPath objects *)
  288. cache : pointer;
  289. (* Resource limits *)
  290. opLimit : culong;
  291. opCount : culong;
  292. depth : cint;
  293. maxDepth : cint;
  294. maxParserDepth : cint;
  295. end;
  296. (*
  297. * The structure of a compiled expression form is not public.
  298. *)
  299. xmlXPathCompExpr = record end;
  300. (**
  301. * xmlXPathParserContext:
  302. *
  303. * An XPath parser context. It contains pure parsing informations,
  304. * an xmlXPathContext, and the stack of objects.
  305. *)
  306. xmlXPathParserContext = record
  307. cur : xmlCharPtr; (* the current AnsiChar being parsed *)
  308. base : xmlCharPtr; (* the full expression *)
  309. error : cint; (* error code *)
  310. context : xmlXPathContextPtr; (* the evaluation context *)
  311. value : xmlXPathObjectPtr; (* the current value *)
  312. valueNr : cint; (* number of values stacked *)
  313. valueMax : cint; (* max number of values stacked *)
  314. valueTab : xmlXPathObjectPtrPtr; (* stack of values *)
  315. comp : xmlXPathCompExprPtr; (* the precompiled expression *)
  316. xptr : cint; (* it this an XPointer expression *)
  317. ancestor : xmlNodePtr; (* used for walking preceding axis *)
  318. valueFrame : cint; (* used to limit Pop on the stack *)
  319. end;
  320. {$ENDIF}
  321. {$IFDEF FUNCTION}
  322. (************************************************************************
  323. * *
  324. * Public API *
  325. * *
  326. ************************************************************************)
  327. procedure xmlXPathFreeObject(obj: xmlXPathObjectPtr); EXTDECL; external xml2lib;
  328. function xmlXPathNodeSetCreate(val: xmlNodePtr): xmlNodeSetPtr; EXTDECL; external xml2lib;
  329. procedure xmlXPathFreeNodeSetList(obj: xmlXPathObjectPtr); EXTDECL; external xml2lib;
  330. procedure xmlXPathFreeNodeSet(obj: xmlNodeSetPtr); EXTDECL; external xml2lib;
  331. function xmlXPathObjectCopy(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  332. function xmlXPathCmpNodes(node1, node2: xmlNodePtr): cint; EXTDECL; external xml2lib;
  333. (**
  334. * Conversion functions to basic types.
  335. *)
  336. function xmlXPathCastNumberToBoolean(val: cdouble): cint; EXTDECL; external xml2lib;
  337. function xmlXPathCastStringToBoolean(val: xmlCharPtr): cint; EXTDECL; external xml2lib;
  338. function xmlXPathCastNodeSetToBoolean(ns: xmlNodeSetPtr): cint; EXTDECL; external xml2lib;
  339. function xmlXPathCastToBoolean(ns: xmlXPathObjectPtr): cint; EXTDECL; external xml2lib;
  340. function xmlXPathCastBooleanToNumber(val: cint): cdouble; EXTDECL; external xml2lib;
  341. function xmlXPathCastStringToNumber(val: xmlCharPtr): cdouble; EXTDECL; external xml2lib;
  342. function xmlXPathCastNodeToNumber(val: xmlNodePtr): cdouble; EXTDECL; external xml2lib;
  343. function xmlXPathCastNodeSetToNumber(val: xmlNodeSetPtr): cdouble; EXTDECL; external xml2lib;
  344. function xmlXPathCastToNumber(val: xmlXPathObjectPtr): cdouble; EXTDECL; external xml2lib;
  345. function xmlXPathCastBooleanToString(val: cint): xmlCharPtr; EXTDECL; external xml2lib;
  346. function xmlXPathCastNumberToString(val: cdouble): xmlCharPtr; EXTDECL; external xml2lib;
  347. function xmlXPathCastNodeToString(val: xmlNodePtr): xmlCharPtr; EXTDECL; external xml2lib;
  348. function xmlXPathCastNodeSetToString(val: xmlNodeSetPtr): xmlCharPtr; EXTDECL; external xml2lib;
  349. function xmlXPathCastToString(val: xmlXPathObjectPtr): xmlCharPtr; EXTDECL; external xml2lib;
  350. function xmlXPathConvertBoolean(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  351. function xmlXPathConvertNumber(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  352. function xmlXPathConvertString(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  353. (**
  354. * Context handling.
  355. *)
  356. function xmlXPathNewContext(doc: xmlDocPtr): xmlXPathContextPtr; EXTDECL; external xml2lib;
  357. procedure xmlXPathFreeContext(ctxt: xmlXPathContextPtr); EXTDECL; external xml2lib;
  358. function xmlXPathContextSetCache(ctxt: xmlXPathContextPtr; active, value, options: cint): cint; EXTDECL; external xml2lib;
  359. (**
  360. * Evaluation functions.
  361. *)
  362. function xmlXPathOrderDocElems(doc: xmlDocPtr): clong; EXTDECL; external xml2lib;
  363. function xmlXPathSetContextNode(node: xmlNodePtr; ctx: xmlXPathContextPtr): cint; EXTDECL; external xml2lib;
  364. function xmlXPathNodeEval(node: xmlNodePtr; const str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  365. function xmlXPathEval(str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  366. function xmlXPathEvalExpression(str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  367. function xmlXPathEvalPredicate(ctxt: xmlXPathContextPtr; res: xmlXPathObjectPtr): cint; EXTDECL; external xml2lib;
  368. (**
  369. * Separate compilation/evaluation entry points.
  370. *)
  371. function xmlXPathCompile(str: xmlCharPtr): xmlXPathCompExprPtr; EXTDECL; external xml2lib;
  372. function xmlXPathCtxtCompile(ctxt: xmlXPathContextPtr; str: xmlCharPtr): xmlXPathCompExprPtr; EXTDECL; external xml2lib;
  373. function xmlXPathCompiledEval(comp: xmlXPathCompExprPtr; ctxt: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL; external xml2lib;
  374. function xmlXPathCompiledEvalToBoolean(comp: xmlXPathCompExprPtr; ctxt: xmlXPathContextPtr): cint; EXTDECL; external xml2lib;
  375. procedure xmlXPathFreeCompExpr(comp: xmlXPathCompExprPtr); EXTDECL; external xml2lib;
  376. {$ENDIF}
  377. {$IFDEF FUNCTIONVAR}
  378. (************************************************************************
  379. * *
  380. * Public API *
  381. * *
  382. ************************************************************************)
  383. xmlXPathFreeObject: procedure(obj: xmlXPathObjectPtr); EXTDECL;
  384. xmlXPathNodeSetCreate: function(val: xmlNodePtr): xmlNodeSetPtr; EXTDECL;
  385. xmlXPathFreeNodeSetList: procedure(obj: xmlXPathObjectPtr); EXTDECL;
  386. xmlXPathFreeNodeSet: procedure(obj: xmlNodeSetPtr); EXTDECL;
  387. xmlXPathObjectCopy: function(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL;
  388. xmlXPathCmpNodes: function(node1, node2: xmlNodePtr): cint; EXTDECL;
  389. (**
  390. * Conversion functions to basic types.
  391. *)
  392. xmlXPathCastNumberToBoolean: function(val: cdouble): cint; EXTDECL;
  393. xmlXPathCastStringToBoolean: function(val: xmlCharPtr): cint; EXTDECL;
  394. xmlXPathCastNodeSetToBoolean: function(ns: xmlNodeSetPtr): cint; EXTDECL;
  395. xmlXPathCastToBoolean: function(ns: xmlXPathObjectPtr): cint; EXTDECL;
  396. xmlXPathCastBooleanToNumber: function(val: cint): cdouble; EXTDECL;
  397. xmlXPathCastStringToNumber: function(val: xmlCharPtr): cdouble; EXTDECL;
  398. xmlXPathCastNodeToNumber: function(val: xmlNodePtr): cdouble; EXTDECL;
  399. xmlXPathCastNodeSetToNumber: function(val: xmlNodeSetPtr): cdouble; EXTDECL;
  400. xmlXPathCastToNumber: function(val: xmlXPathObjectPtr): cdouble; EXTDECL;
  401. xmlXPathCastBooleanToString: function(val: cint): xmlCharPtr; EXTDECL;
  402. xmlXPathCastNumberToString: function(val: cdouble): xmlCharPtr; EXTDECL;
  403. xmlXPathCastNodeToString: function(val: xmlNodePtr): xmlCharPtr; EXTDECL;
  404. xmlXPathCastNodeSetToString: function(val: xmlNodeSetPtr): xmlCharPtr; EXTDECL;
  405. xmlXPathCastToString: function(val: xmlXPathObjectPtr): xmlCharPtr; EXTDECL;
  406. xmlXPathConvertBoolean: function(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL;
  407. xmlXPathConvertNumber: function(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL;
  408. xmlXPathConvertString: function(val: xmlXPathObjectPtr): xmlXPathObjectPtr; EXTDECL;
  409. (**
  410. * Context handling.
  411. *)
  412. xmlXPathNewContext: function(doc: xmlDocPtr): xmlXPathContextPtr; EXTDECL;
  413. xmlXPathFreeContext: procedure(ctxt: xmlXPathContextPtr); EXTDECL;
  414. xmlXPathContextSetCache: function(ctxt: xmlXPathContextPtr; active, value, options: cint): cint; EXTDECL;
  415. (**
  416. * Evaluation functions.
  417. *)
  418. xmlXPathOrderDocElems: function(doc: xmlDocPtr): clong; EXTDECL;
  419. xmlXPathSetContextNode: function(node: xmlNodePtr; ctx: xmlXPathContextPtr): cint; EXTDECL;
  420. xmlXPathNodeEval: function(node: xmlNodePtr; const str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL;
  421. xmlXPathEval: function(str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL;
  422. xmlXPathEvalExpression: function(str: xmlCharPtr; ctx: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL;
  423. xmlXPathEvalPredicate: function(ctxt: xmlXPathContextPtr; res: xmlXPathObjectPtr): cint; EXTDECL;
  424. (**
  425. * Separate compilation/evaluation entry points.
  426. *)
  427. xmlXPathCompile: function(str: xmlCharPtr): xmlXPathCompExprPtr; EXTDECL;
  428. xmlXPathCtxtCompile: function(ctxt: xmlXPathContextPtr; str: xmlCharPtr): xmlXPathCompExprPtr; EXTDECL;
  429. xmlXPathCompiledEval: function(comp: xmlXPathCompExprPtr; ctxt: xmlXPathContextPtr): xmlXPathObjectPtr; EXTDECL;
  430. xmlXPathCompiledEvalToBoolean: function(comp: xmlXPathCompExprPtr; ctxt: xmlXPathContextPtr): cint; EXTDECL;
  431. xmlXPathFreeCompExpr: procedure(comp: xmlXPathCompExprPtr); EXTDECL;
  432. {$ENDIF}
  433. {$IFDEF EXTVAR}
  434. (**
  435. * Objects and Nodesets handling
  436. *)
  437. {$IFNDEF NO_EXTERNAL_VARS}
  438. var
  439. xmlXPathNAN: cdouble; cvar; external;
  440. xmlXPathPINF: cdouble; cvar; external;
  441. xmlXPathNINF: cdouble; cvar; external;
  442. {$ENDIF}
  443. {$ENDIF}
  444. {$IFDEF MACRO}
  445. (* These macros may later turn into functions *)
  446. (**
  447. * xmlXPathNodeSetGetLength:
  448. * @ns: a node-set
  449. *
  450. * Implement a functionality similar to the DOM NodeList.length.
  451. *
  452. * Returns the number of nodes in the node-set.
  453. *)
  454. function xmlXPathNodeSetGetLength(ns: xmlNodeSetPtr): cint;
  455. (**
  456. * xmlXPathNodeSetItem:
  457. * @ns: a node-set
  458. * @index: index of a node in the set
  459. *
  460. * Implements a functionality similar to the DOM NodeList.item().
  461. *
  462. * Returns the xmlNodePtr at the given @index in @ns or NULL if
  463. * @index is out of range (0 to length-1)
  464. *)
  465. function xmlXPathNodeSetItem(ns: xmlNodeSetPtr; index: cint): xmlNodePtr;
  466. (**
  467. * xmlXPathNodeSetIsEmpty:
  468. * @ns: a node-set
  469. *
  470. * Checks whether @ns is empty or not.
  471. *
  472. * Returns %TRUE if @ns is an empty node-set.
  473. *)
  474. function xmlXPathNodeSetIsEmpty(ns: xmlNodeSetPtr): boolean;
  475. {$ENDIF}
  476. {$ENDIF} (* LIBXML_XPATH_ENABLED *)
  477. {$if defined(LIBXML_XPATH_ENABLED) or defined(LIBXML_SCHEMAS_ENABLED)}
  478. {$IFDEF FUNCTIONVAR}
  479. xmlXPathInit: procedure; EXTDECL;
  480. xmlXPathIsNaN: function(val: cdouble): cint; EXTDECL;
  481. xmlXPathIsInf: function(val: cdouble): cint; EXTDECL;
  482. {$ENDIF}
  483. {$ENDIF} (* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*)