1 * Summary: XML Path Language implementation
2 * Description: API for the XML Path Language implementation
4 * XML Path Language implementation
5 * XPath is a language for addressing parts of an XML document,
6 * designed to be used by both XSLT and XPointer
7 * http://www.w3.org/TR/xpath
10 * W3C Recommendation 16 November 1999
11 * http://www.w3.org/TR/1999/REC-xpath-19991116
13 * Copy: See Copyright for the status of this software.
15 * Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
17 /if not defined(XML_XPATH_H__)
20 /include "libxmlrpg/xmlversion"
22 /if defined(LIBXML_XPATH_ENABLED)
24 /include "libxmlrpg/xmlerror"
25 /include "libxmlrpg/tree"
26 /include "libxmlrpg/hash"
27 /endif LIBXML_XPATH_ENABLED
29 /if defined(LIBXML_XPATH_ENABLED)
31 d xmlXPathContextPtr...
32 d s * based(######typedef######)
34 d xmlXPathParserContextPtr...
35 d s * based(######typedef######)
37 * The set of XPath error codes.
39 d xmlXPathError s 10i 0 based(######typedef######) enum
40 d XPATH_EXPRESSION_OK...
42 d XPATH_NUMBER_ERROR...
44 d XPATH_UNFINISHED_LITERAL_ERROR...
46 d XPATH_START_LITERAL_ERROR...
48 d XPATH_VARIABLE_REF_ERROR...
50 d XPATH_UNDEF_VARIABLE_ERROR...
52 d XPATH_INVALID_PREDICATE_ERROR...
56 d XPATH_UNCLOSED_ERROR...
58 d XPATH_UNKNOWN_FUNC_ERROR...
60 d XPATH_INVALID_OPERAND...
62 d XPATH_INVALID_TYPE...
64 d XPATH_INVALID_ARITY...
66 d XPATH_INVALID_CTXT_SIZE...
68 d XPATH_INVALID_CTXT_POSITION...
70 d XPATH_MEMORY_ERROR...
72 d XPTR_SYNTAX_ERROR...
74 d XPTR_RESOURCE_ERROR...
76 d XPTR_SUB_RESOURCE_ERROR...
78 d XPATH_UNDEF_PREFIX_ERROR...
80 d XPATH_ENCODING_ERROR...
82 d XPATH_INVALID_CHAR_ERROR...
84 d XPATH_INVALID_CTXT...
86 d XPATH_STACK_ERROR...
88 d XPATH_FORBID_VARIABLE_ERROR...
91 * A node-set (an unordered collection of nodes without duplicates).
93 d xmlNodeSetPtr s * based(######typedef######)
95 d xmlNodeSet ds based(xmlNodeSetPtr)
97 d nodeNr 10i 0 Set node count
98 d nodeMax 10i 0 Max # nodes in set
99 d nodeTab * xmlNodePtr *
101 * An expression is evaluated to yield an object, which
102 * has one of the following four basic types:
108 * @@ XPointer will add more types !
110 d xmlXPathObjectType...
111 d s 10i 0 based(######typedef######) enum
120 d XPATH_LOCATIONSET...
123 d XPATH_XSLT_TREE... R/O XSLT value tree
126 d xmlXPathObjectPtr...
127 d s * based(######typedef######)
129 d xmlXPathObject ds based(xmlXPathObjectPtr)
131 d type like(xmlXPathObjectType)
132 d nodesetval like(xmlNodeSetPtr)
135 d stringval * xmlChar *
141 * xmlXPathConvertFunc:
142 * @obj: an XPath object
143 * @type: the number of the target type
145 * A conversion function is associated to a type and used to cast
146 * the new type to primitive values.
148 * Returns -1 in case of error, 0 otherwise
150 d xmlXPathConvertFunc...
151 d s * based(######typedef######)
154 * Extra type: a name and a conversion function.
157 d s * based(######typedef######)
159 d xmlXPathType ds based(xmlXPathTypePtr)
161 d name * The type name
162 d func like(xmlXPathConvertFunc) Conversion function
164 * Extra variable: a name and a value.
166 d xmlXPathVariablePtr...
167 d s * based(######typedef######)
169 d xmlXPathVariable...
170 d ds based(xmlXPathVariablePtr)
172 d name * The variable name
173 d value like(xmlXPathObjectPtr) The value
176 * @ctxt: an XPath parser context
177 * @nargs: the number of arguments passed to the function
179 * An XPath evaluation function, the parameters are on the XPath
182 d xmlXPathEvalFunc...
183 d s * based(######typedef######)
186 * Extra function: a name and an evaluation function.
189 d s * based(######typedef######)
191 d xmlXPathFunct ds based(xmlXPathFuncPtr)
193 d name * The function name
194 d func like(xmlXPathEvalFunc) Evaluation function
197 * @ctxt: the XPath interpreter context
198 * @cur: the previous node being explored on that axis
200 * An axis traversal function. To traverse an axis, the engine calls
201 * the first time with cur == NULL and repeat until the function returns
202 * NULL indicating the end of the axis traversal.
204 * Returns the next node in that axis or NULL if at the end of the axis.
206 d xmlXPathAxisFunc...
207 d s * based(######typedef######)
210 * Extra axis: a name and an axis function.
213 d s * based(######typedef######)
215 d xmlXPathAxis ds based(xmlXPathAxisPtr)
217 d name * The axis name
218 d func like(xmlXPathAxisFunc) The search function
221 * @ctxt: the XPath interprestation context
222 * @nargs: the number of arguments
225 * The arguments (if any) are popped out from the context stack
226 * and the result is pushed on the stack.
228 d xmlXPathFunction...
229 d s * based(######typedef######)
232 * Function and Variable Lookup.
234 * xmlXPathVariableLookupFunc:
235 * @ctxt: an XPath context
236 * @name: name of the variable
237 * @ns_uri: the namespace name hosting this variable
239 * Prototype for callbacks used to plug variable lookup in the XPath
242 * Returns the XPath object value or NULL if not found.
244 d xmlXPathVariableLookupFunc...
245 d s * based(######typedef######)
248 * xmlXPathFuncLookupFunc:
249 * @ctxt: an XPath context
250 * @name: name of the function
251 * @ns_uri: the namespace name hosting this function
253 * Prototype for callbacks used to plug function lookup in the XPath
256 * Returns the XPath function or NULL if not found.
258 d xmlXPathFuncLookupFunc...
259 d s * based(######typedef######)
263 * Flags for XPath engine compilation and runtime
267 * check namespaces at compilation
269 d XML_XPATH_CHECKNS...
274 * forbid variables in expression
281 * Expression evaluation occurs with respect to a context.
282 * he context consists of:
283 * - a node (the context node)
284 * - a node list (the context node list)
285 * - a set of variable bindings
286 * - a function library
287 * - the set of namespace declarations in scope for the expression
288 * Following the switch to hash tables, this need to be trimmed up at
289 * the next binary incompatible release.
290 * The node may be modified when the context is passed to libxml2
291 * for an XPath evaluation so you may need to initialize it again
292 * before the next call.
295 d ds based(xmlXPathContextPtr)
297 d doc like(xmlDocPtr) Current document
298 d node like(xmlNodePtr) Current node
300 d nb_variables_unused... Unused (hash table)
302 d max_variables_unused... Unused (hash table)
304 d varHash like(xmlHashTablePtr) Defined variables
306 d nb_types 10i 0 # of defined types
307 d max_types 10i 0 Max number of types
308 d types like(xmlXPathTypePtr) Defined types array
310 d nb_funcs_unused... Unused (hash table)
312 d max_funcs_unused... Unused (hash table)
314 d funcHash like(xmlHashTablePtr) Defined functions
316 d nb_axis 10i 0 # of defined axis
317 d max_axis 10i 0 Max number of axis
318 d axis like(xmlXPathAxisPtr) Defined axis array
320 * the namespace nodes of the context node
322 d namespaces * xmlNsPtr *
323 d nsNr 10i 0 # scope namespaces
324 d user * procptr Function to free
328 d contextSize 10i 0 The context size
329 d proximityPosition...
332 * extra stuff for XPointer
334 d xptr 10i 0 XPointer context ?
335 d here like(xmlNodePtr) For here()
336 d origin like(xmlNodePtr) For origin()
338 * the set of namespace declarations in scope for the expression
340 d nsHash like(xmlHashTablePtr) Namespace hashtable
341 d varLookupFunc like(xmlXPathVariableLookupFunc) Var lookup function
342 d varLookupData * void *
344 * Possibility to link in an extra item
348 * The function name and URI when calling a function
350 d function * const xmlChar *
351 d functionURI * const xmlChar *
353 * function lookup function and data
355 d funcLookupFunc... Func lookup func
356 d like(xmlXPathVariableLookupFunc)
357 d funcLookupData... void *
360 * temporary namespace lists kept for walking the namespace axis
362 d tmpNsList * xmlNsPtr *
363 d tmpNsNr 10i 0 # scope namespaces
365 * error reporting mechanism
368 d error like(xmlStructuredErrorFunc) Error callback
369 d lastError like(xmlError) The last error
370 d debugNode like(xmlNodePtr) XSLT source node
374 d dict like(xmlDictPtr) Dictionary if any
376 d flags 10i 0 Compilation control
378 * Cache for reusal of XPath objects
382 * The structure of a compiled expression form is not public.
384 d xmlXPathCompExprPtr...
385 d s * based(######typedef######)
387 * xmlXPathParserContext:
389 * An XPath parser context. It contains pure parsing informations,
390 * an xmlXPathContext, and the stack of objects.
392 d xmlXPathParserContext...
393 d ds based(xmlXPathParserContextPtr)
395 d cur * const xmlChar *
396 d base * const xmlChar *
398 d error 10i 0 Error code
400 d context like(xmlXPathContextPtr) Evaluation context
401 d value like(xmlXPathObjectPtr) The current value
402 d valueNr 10i 0 Value stack depth
403 d valueMax 10i 0 Max stack depth
404 d valueTab * xmlXPathObjectPtr *
406 d comp like(xmlXPathCompExprPtr) Precompiled expr.
407 d xptr 10i 0 XPointer expression?
408 d ancestor like(xmlNodePtr) To walk prec. axis
410 d valueFrame 10i 0 Limit stack pop
412 **************************************************************************
416 **************************************************************************
418 * Objects and Nodesets handling
420 d xmlXPathNAN s 8f import('xmlXPathNAN')
421 d xmlXPathPINF s 8f import('xmlXPathPINF')
422 d xmlXPathNINF s 8f import('xmlXPathNINF')
424 d xmlXPathFreeObject...
425 d pr extproc('xmlXPathFreeObject')
426 d obj value like(xmlXPathObjectPtr)
428 d xmlXPathNodeSetCreate...
429 d pr extproc('xmlXPathNodeSetCreate')
430 d like(xmlNodeSetPtr)
431 d val value like(xmlNodePtr)
433 d xmlXPathFreeNodeSetList...
434 d pr extproc('xmlXPathFreeNodeSetList')
435 d obj value like(xmlXPathObjectPtr)
437 d xmlXPathFreeNodeSet...
438 d pr extproc('xmlXPathFreeNodeSet')
439 d obj value like(xmlNodeSetPtr)
441 d xmlXPathObjectCopy...
442 d pr extproc('xmlXPathObjectCopy')
443 d like(xmlXPathObjectPtr)
444 d val value like(xmlXPathObjectPtr)
446 d xmlXPathCmpNodes...
447 d pr 10i 0 extproc('xmlXPathCmpNodes')
448 d node1 value like(xmlNodePtr)
449 d node2 value like(xmlNodePtr)
451 * Conversion functions to basic types.
453 d xmlXPathCastNumberToBoolean...
455 d 'xmlXPathCastNumberToBoolean')
458 d xmlXPathCastStringToBoolean...
460 d 'xmlXPathCastStringToBoolean')
461 d val * value options(*string) const xmlChar *
463 d xmlXPathCastNodeSetToBoolean...
465 d 'xmlXPathCastNodeSetToBoolean')
466 d ns value like(xmlNodeSetPtr)
468 d xmlXPathCastToBoolean...
469 d pr 10i 0 extproc('xmlXPathCastToBoolean')
470 d val value like(xmlXPathObjectPtr)
472 d xmlXPathCastBooleanToNumber...
474 d 'xmlXPathCastBooleanToNumber')
478 d xmlXPathCastStringToNumber...
479 d pr 8f extproc('xmlXPathCastStringToNumber')
480 d val * value options(*string) const xmlChar *
482 d xmlXPathCastNodeToNumber...
483 d pr 8f extproc('xmlXPathCastNodeToNumber')
484 d node value like(xmlNodePtr)
486 d xmlXPathCastNodeSetToNumber...
488 d 'xmlXPathCastNodeSetToNumber')
489 d ns value like(xmlNodeSetPtr)
491 d xmlXPathCastToNumber...
492 d pr 8f extproc('xmlXPathCastToNumber')
493 d val value like(xmlXPathObjectPtr)
495 d xmlXPathCastBooleanToString...
496 d pr * extproc( xmlChar *
497 d 'xmlXPathCastBooleanToString')
500 d xmlXPathCastNumberToString...
501 d pr * extproc('xmlXPathCastNumberToString')xmlChar *
504 d xmlXPathCastNodeToString...
505 d pr * extproc('xmlXPathCastNodeToString') xmlChar *
506 d node value like(xmlNodePtr)
508 d xmlXPathCastNodeSetToString...
509 d pr * extproc('xmlXPathCastNodeSetToString'xmlChar *
511 d ns value like(xmlNodeSetPtr)
513 d xmlXPathCastToString...
514 d pr * extproc('xmlXPathCastToString') xmlChar *
515 d val value like(xmlXPathObjectPtr)
517 d xmlXPathConvertBoolean...
518 d pr extproc('xmlXPathConvertBoolean')
519 d like(xmlXPathObjectPtr)
520 d val value like(xmlXPathObjectPtr)
522 d xmlXPathConvertNumber...
523 d pr extproc('xmlXPathConvertNumber')
524 d like(xmlXPathObjectPtr)
525 d val value like(xmlXPathObjectPtr)
527 d xmlXPathConvertString...
528 d pr extproc('xmlXPathConvertString')
529 d like(xmlXPathObjectPtr)
530 d val value like(xmlXPathObjectPtr)
534 d xmlXPathNewContext...
535 d pr extproc('xmlXPathNewContext')
536 d like(xmlXPathContextPtr)
537 d doc value like(xmlDocPtr)
539 d xmlXPathFreeContext...
540 d pr extproc('xmlXPathFreeContext')
541 d ctxt value like(xmlXPathContextPtr)
543 d xmlXPathContextSetCache...
544 d pr 10i 0 extproc('xmlXPathContextSetCache')
545 d ctxt value like(xmlXPathContextPtr)
548 d options 10i 0 value
550 * Evaluation functions.
552 d xmlXPathOrderDocElems...
553 d pr 20i 0 extproc('xmlXPathOrderDocElems')
554 d doc value like(xmlDocPtr)
556 d xmlXPathSetContextNode...
557 d pr 10i 0 extproc('xmlXPathSetContextNode')
558 d node value like(xmlNodePtr)
559 d ctx value like(xmlXPathContextPtr)
561 d xmlXPathNodeEval...
562 d pr extproc('xmlXPathNodeEval')
563 d like(xmlXPathObjectPtr)
564 d node value like(xmlNodePtr)
565 d str * value options(*string) const xmlChar *
566 d ctx value like(xmlXPathContextPtr)
568 d xmlXPathEval pr extproc('xmlXPathEval')
569 d like(xmlXPathObjectPtr)
570 d str * value options(*string) const xmlChar *
571 d ctx value like(xmlXPathContextPtr)
573 d xmlXPathEvalExpression...
574 d pr extproc('xmlXPathEvalExpression')
575 d like(xmlXPathObjectPtr)
576 d str * value options(*string) const xmlChar *
577 d ctxt value like(xmlXPathContextPtr)
579 d xmlXPathEvalPredicate...
580 d pr 10i 0 extproc('xmlXPathEvalPredicate')
581 d ctxt value like(xmlXPathContextPtr)
582 d res value like(xmlXPathObjectPtr)
584 * Separate compilation/evaluation entry points.
587 d pr extproc('xmlXPathCompile')
588 d like(xmlXPathCompExprPtr)
589 d str * value options(*string) const xmlChar *
591 d xmlXPathCtxtCompile...
592 d pr extproc('xmlXPathCtxtCompile')
593 d like(xmlXPathCompExprPtr)
594 d ctxt value like(xmlXPathContextPtr)
595 d str * value options(*string) const xmlChar *
597 d xmlXPathCompiledEval...
598 d pr extproc('xmlXPathCompiledEval')
599 d like(xmlXPathObjectPtr)
600 d comp value like(xmlXPathCompExprPtr)
601 d ctx value like(xmlXPathContextPtr)
603 d xmlXPathCompiledEvalToBoolean...
605 d 'xmlXPathCompiledEvalToBoolean')
606 d comp value like(xmlXPathCompExprPtr)
607 d ctxt value like(xmlXPathContextPtr)
609 d xmlXPathFreeCompExpr...
610 d pr extproc('xmlXPathFreeCompExpr')
611 d comp value like(xmlXPathCompExprPtr)
612 /endif LIBXML_XPATH_ENABLED
614 /undefine XML_TESTVAL
615 /if defined(LIBXML_XPATH_ENABLED)
617 /elseif defined(LIBXML_SCHEMAS_ENABLED)
620 /if defined(XML_TESTVAL)
621 d xmlXPathInit pr extproc('xmlXPathInit')
623 d xmlXPathIsNaN pr 10i 0 extproc('xmlXPathIsNaN')
626 d xmlXPathIsInf pr 10i 0 extproc('xmlXPathIsInf')
629 /undefine XML_TESTVAL
632 * C macros implemented as procedures for ILE/RPG support.
634 /if defined(LIBXML_XPATH_ENABLED)
635 d xmlXPathNodeSetGetLength...
636 d pr 10i 0 extproc('__xmlXPathNodeSetGetLength')
637 d ns value like(xmlNodeSetPtr)
639 d xmlXPathNodeSetItem...
640 d pr extproc('__xmlXPathNodeSetItem')
642 d ns value like(xmlNodeSetPtr)
645 d xmlXPathNodeSetIsEmpty...
646 d pr 10i 0 extproc('__xmlXPathNodeSetIsEmpty')
647 d ns value like(xmlNodeSetPtr)
648 /endif LIBXML_XPATH_ENABLED