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/xmlTypesC"
25 /include "libxmlrpg/xmlerror"
26 /include "libxmlrpg/tree"
27 /include "libxmlrpg/hash"
28 /endif LIBXML_XPATH_ENABLED
30 /if defined(LIBXML_XPATH_ENABLED)
32 d xmlXPathContextPtr...
33 d s * based(######typedef######)
35 d xmlXPathParserContextPtr...
36 d s * based(######typedef######)
38 * The set of XPath error codes.
40 d xmlXPathError s based(######typedef######)
42 d XPATH_EXPRESSION_OK...
44 d XPATH_NUMBER_ERROR...
46 d XPATH_UNFINISHED_LITERAL_ERROR...
48 d XPATH_START_LITERAL_ERROR...
50 d XPATH_VARIABLE_REF_ERROR...
52 d XPATH_UNDEF_VARIABLE_ERROR...
54 d XPATH_INVALID_PREDICATE_ERROR...
58 d XPATH_UNCLOSED_ERROR...
60 d XPATH_UNKNOWN_FUNC_ERROR...
62 d XPATH_INVALID_OPERAND...
64 d XPATH_INVALID_TYPE...
66 d XPATH_INVALID_ARITY...
68 d XPATH_INVALID_CTXT_SIZE...
70 d XPATH_INVALID_CTXT_POSITION...
72 d XPATH_MEMORY_ERROR...
74 d XPTR_SYNTAX_ERROR...
76 d XPTR_RESOURCE_ERROR...
78 d XPTR_SUB_RESOURCE_ERROR...
80 d XPATH_UNDEF_PREFIX_ERROR...
82 d XPATH_ENCODING_ERROR...
84 d XPATH_INVALID_CHAR_ERROR...
86 d XPATH_INVALID_CTXT...
88 d XPATH_STACK_ERROR...
90 d XPATH_FORBID_VARIABLE_ERROR...
93 * A node-set (an unordered collection of nodes without duplicates).
95 d xmlNodeSetPtr s * based(######typedef######)
97 d xmlNodeSet ds based(xmlNodeSetPtr)
99 d nodeNr like(xmlCint) Set node count
100 d nodeMax like(xmlCint) Max # nodes in set
101 d nodeTab * xmlNodePtr *
103 * An expression is evaluated to yield an object, which
104 * has one of the following four basic types:
110 * @@ XPointer will add more types !
112 d xmlXPathObjectType...
113 d s based(######typedef######)
123 d XPATH_LOCATIONSET...
126 d XPATH_XSLT_TREE... R/O XSLT value tree
129 d xmlXPathObjectPtr...
130 d s * based(######typedef######)
132 d xmlXPathObject ds based(xmlXPathObjectPtr)
134 d type like(xmlXPathObjectType)
135 d nodesetval like(xmlNodeSetPtr)
136 d boolval like(xmlCint)
137 d floatval like(xmlCdouble)
138 d stringval * xmlChar *
140 d index like(xmlCint)
142 d index2 like(xmlCint)
144 * xmlXPathConvertFunc:
145 * @obj: an XPath object
146 * @type: the number of the target type
148 * A conversion function is associated to a type and used to cast
149 * the new type to primitive values.
151 * Returns -1 in case of error, 0 otherwise
153 d xmlXPathConvertFunc...
154 d s * based(######typedef######)
157 * Extra type: a name and a conversion function.
160 d s * based(######typedef######)
162 d xmlXPathType ds based(xmlXPathTypePtr)
164 d name * The type name
165 d func like(xmlXPathConvertFunc) Conversion function
167 * Extra variable: a name and a value.
169 d xmlXPathVariablePtr...
170 d s * based(######typedef######)
172 d xmlXPathVariable...
173 d ds based(xmlXPathVariablePtr)
175 d name * The variable name
176 d value like(xmlXPathObjectPtr) The value
179 * @ctxt: an XPath parser context
180 * @nargs: the number of arguments passed to the function
182 * An XPath evaluation function, the parameters are on the XPath
185 d xmlXPathEvalFunc...
186 d s * based(######typedef######)
189 * Extra function: a name and an evaluation function.
192 d s * based(######typedef######)
194 d xmlXPathFunct ds based(xmlXPathFuncPtr)
196 d name * The function name
197 d func like(xmlXPathEvalFunc) Evaluation function
200 * @ctxt: the XPath interpreter context
201 * @cur: the previous node being explored on that axis
203 * An axis traversal function. To traverse an axis, the engine calls
204 * the first time with cur == NULL and repeat until the function returns
205 * NULL indicating the end of the axis traversal.
207 * Returns the next node in that axis or NULL if at the end of the axis.
209 d xmlXPathAxisFunc...
210 d s * based(######typedef######)
213 * Extra axis: a name and an axis function.
216 d s * based(######typedef######)
218 d xmlXPathAxis ds based(xmlXPathAxisPtr)
220 d name * The axis name
221 d func like(xmlXPathAxisFunc) The search function
224 * @ctxt: the XPath interprestation context
225 * @nargs: the number of arguments
228 * The arguments (if any) are popped out from the context stack
229 * and the result is pushed on the stack.
231 d xmlXPathFunction...
232 d s * based(######typedef######)
235 * Function and Variable Lookup.
237 * xmlXPathVariableLookupFunc:
238 * @ctxt: an XPath context
239 * @name: name of the variable
240 * @ns_uri: the namespace name hosting this variable
242 * Prototype for callbacks used to plug variable lookup in the XPath
245 * Returns the XPath object value or NULL if not found.
247 d xmlXPathVariableLookupFunc...
248 d s * based(######typedef######)
251 * xmlXPathFuncLookupFunc:
252 * @ctxt: an XPath context
253 * @name: name of the function
254 * @ns_uri: the namespace name hosting this function
256 * Prototype for callbacks used to plug function lookup in the XPath
259 * Returns the XPath function or NULL if not found.
261 d xmlXPathFuncLookupFunc...
262 d s * based(######typedef######)
266 * Flags for XPath engine compilation and runtime
270 * check namespaces at compilation
272 d XML_XPATH_CHECKNS...
277 * forbid variables in expression
284 * Expression evaluation occurs with respect to a context.
285 * he context consists of:
286 * - a node (the context node)
287 * - a node list (the context node list)
288 * - a set of variable bindings
289 * - a function library
290 * - the set of namespace declarations in scope for the expression
291 * Following the switch to hash tables, this need to be trimmed up at
292 * the next binary incompatible release.
293 * The node may be modified when the context is passed to libxml2
294 * for an XPath evaluation so you may need to initialize it again
295 * before the next call.
298 d ds based(xmlXPathContextPtr)
300 d doc like(xmlDocPtr) Current document
301 d node like(xmlNodePtr) Current node
303 d nb_variables_unused... Unused (hash table)
305 d max_variables_unused... Unused (hash table)
307 d varHash like(xmlHashTablePtr) Defined variables
309 d nb_types like(xmlCint) # of defined types
310 d max_types like(xmlCint) Max number of types
311 d types like(xmlXPathTypePtr) Defined types array
313 d nb_funcs_unused... Unused (hash table)
315 d max_funcs_unused... Unused (hash table)
317 d funcHash like(xmlHashTablePtr) Defined functions
319 d nb_axis like(xmlCint) # of defined axis
320 d max_axis like(xmlCint) Max number of axis
321 d axis like(xmlXPathAxisPtr) Defined axis array
323 * the namespace nodes of the context node
325 d namespaces * xmlNsPtr *
326 d nsNr like(xmlCint) # scope namespaces
327 d user * procptr Function to free
331 d contextSize like(xmlCint) The context size
332 d proximityPosition...
335 * extra stuff for XPointer
337 d xptr like(xmlCint) XPointer context ?
338 d here like(xmlNodePtr) For here()
339 d origin like(xmlNodePtr) For origin()
341 * the set of namespace declarations in scope for the expression
343 d nsHash like(xmlHashTablePtr) Namespace hashtable
344 d varLookupFunc like(xmlXPathVariableLookupFunc) Var lookup function
345 d varLookupData * void *
347 * Possibility to link in an extra item
351 * The function name and URI when calling a function
353 d function * const xmlChar *
354 d functionURI * const xmlChar *
356 * function lookup function and data
358 d funcLookupFunc... Func lookup func
359 d like(xmlXPathVariableLookupFunc)
360 d funcLookupData... void *
363 * temporary namespace lists kept for walking the namespace axis
365 d tmpNsList * xmlNsPtr *
366 d tmpNsNr like(xmlCint) # scope namespaces
368 * error reporting mechanism
371 d error like(xmlStructuredErrorFunc) Error callback
372 d lastError likeds(xmlError) The last error
373 d debugNode like(xmlNodePtr) XSLT source node
377 d dict like(xmlDictPtr) Dictionary if any
379 d flags like(xmlCint) Compilation control
381 * Cache for reusal of XPath objects
385 * The structure of a compiled expression form is not public.
387 d xmlXPathCompExprPtr...
388 d s * based(######typedef######)
390 * xmlXPathParserContext:
392 * An XPath parser context. It contains pure parsing informations,
393 * an xmlXPathContext, and the stack of objects.
395 d xmlXPathParserContext...
396 d ds based(xmlXPathParserContextPtr)
398 d cur * const xmlChar *
399 d base * const xmlChar *
401 d error like(xmlCint) Error code
403 d context like(xmlXPathContextPtr) Evaluation context
404 d value like(xmlXPathObjectPtr) The current value
405 d valueNr like(xmlCint) Value stack depth
406 d valueMax like(xmlCint) Max stack depth
407 d valueTab * xmlXPathObjectPtr *
409 d comp like(xmlXPathCompExprPtr) Precompiled expr.
410 d xptr like(xmlCint) XPointer expression?
411 d ancestor like(xmlNodePtr) To walk prec. axis
413 d valueFrame like(xmlCint) Limit stack pop
415 **************************************************************************
419 **************************************************************************
421 * Objects and Nodesets handling
423 d xmlXPathNAN s import('xmlXPathNAN')
426 d xmlXPathPINF s import('xmlXPathPINF')
429 d xmlXPathNINF s import('xmlXPathNINF')
432 d xmlXPathFreeObject...
433 d pr extproc('xmlXPathFreeObject')
434 d obj value like(xmlXPathObjectPtr)
436 d xmlXPathNodeSetCreate...
437 d pr extproc('xmlXPathNodeSetCreate')
438 d like(xmlNodeSetPtr)
439 d val value like(xmlNodePtr)
441 d xmlXPathFreeNodeSetList...
442 d pr extproc('xmlXPathFreeNodeSetList')
443 d obj value like(xmlXPathObjectPtr)
445 d xmlXPathFreeNodeSet...
446 d pr extproc('xmlXPathFreeNodeSet')
447 d obj value like(xmlNodeSetPtr)
449 d xmlXPathObjectCopy...
450 d pr extproc('xmlXPathObjectCopy')
451 d like(xmlXPathObjectPtr)
452 d val value like(xmlXPathObjectPtr)
454 d xmlXPathCmpNodes...
455 d pr extproc('xmlXPathCmpNodes')
457 d node1 value like(xmlNodePtr)
458 d node2 value like(xmlNodePtr)
460 * Conversion functions to basic types.
462 d xmlXPathCastNumberToBoolean...
464 d 'xmlXPathCastNumberToBoolean')
466 d val value like(xmlCdouble)
468 d xmlXPathCastStringToBoolean...
470 d 'xmlXPathCastStringToBoolean')
472 d val * value options(*string) const xmlChar *
474 d xmlXPathCastNodeSetToBoolean...
476 d 'xmlXPathCastNodeSetToBoolean')
478 d ns value like(xmlNodeSetPtr)
480 d xmlXPathCastToBoolean...
481 d pr extproc('xmlXPathCastToBoolean')
483 d val value like(xmlXPathObjectPtr)
485 d xmlXPathCastBooleanToNumber...
487 d 'xmlXPathCastBooleanToNumber')
489 d val value like(xmlCint)
491 d xmlXPathCastStringToNumber...
492 d pr extproc('xmlXPathCastStringToNumber')
494 d val * value options(*string) const xmlChar *
496 d xmlXPathCastNodeToNumber...
497 d pr extproc('xmlXPathCastNodeToNumber')
499 d node value like(xmlNodePtr)
501 d xmlXPathCastNodeSetToNumber...
503 d 'xmlXPathCastNodeSetToNumber')
505 d ns value like(xmlNodeSetPtr)
507 d xmlXPathCastToNumber...
508 d pr extproc('xmlXPathCastToNumber')
510 d val value like(xmlXPathObjectPtr)
512 d xmlXPathCastBooleanToString...
513 d pr * extproc( xmlChar *
514 d 'xmlXPathCastBooleanToString')
515 d val value like(xmlCint)
517 d xmlXPathCastNumberToString...
518 d pr * extproc('xmlXPathCastNumberToString')xmlChar *
519 d val value like(xmlCdouble)
521 d xmlXPathCastNodeToString...
522 d pr * extproc('xmlXPathCastNodeToString') xmlChar *
523 d node value like(xmlNodePtr)
525 d xmlXPathCastNodeSetToString...
526 d pr * extproc('xmlXPathCastNodeSetToString'xmlChar *
528 d ns value like(xmlNodeSetPtr)
530 d xmlXPathCastToString...
531 d pr * extproc('xmlXPathCastToString') xmlChar *
532 d val value like(xmlXPathObjectPtr)
534 d xmlXPathConvertBoolean...
535 d pr extproc('xmlXPathConvertBoolean')
536 d like(xmlXPathObjectPtr)
537 d val value like(xmlXPathObjectPtr)
539 d xmlXPathConvertNumber...
540 d pr extproc('xmlXPathConvertNumber')
541 d like(xmlXPathObjectPtr)
542 d val value like(xmlXPathObjectPtr)
544 d xmlXPathConvertString...
545 d pr extproc('xmlXPathConvertString')
546 d like(xmlXPathObjectPtr)
547 d val value like(xmlXPathObjectPtr)
551 d xmlXPathNewContext...
552 d pr extproc('xmlXPathNewContext')
553 d like(xmlXPathContextPtr)
554 d doc value like(xmlDocPtr)
556 d xmlXPathFreeContext...
557 d pr extproc('xmlXPathFreeContext')
558 d ctxt value like(xmlXPathContextPtr)
560 d xmlXPathContextSetCache...
561 d pr extproc('xmlXPathContextSetCache')
563 d ctxt value like(xmlXPathContextPtr)
564 d active value like(xmlCint)
565 d value value like(xmlCint)
566 d options value like(xmlCint)
568 * Evaluation functions.
570 d xmlXPathOrderDocElems...
571 d pr extproc('xmlXPathOrderDocElems')
573 d doc value like(xmlDocPtr)
575 d xmlXPathSetContextNode...
576 d pr extproc('xmlXPathSetContextNode')
578 d node value like(xmlNodePtr)
579 d ctx value like(xmlXPathContextPtr)
581 d xmlXPathNodeEval...
582 d pr extproc('xmlXPathNodeEval')
583 d like(xmlXPathObjectPtr)
584 d node value like(xmlNodePtr)
585 d str * value options(*string) const xmlChar *
586 d ctx value like(xmlXPathContextPtr)
588 d xmlXPathEval pr extproc('xmlXPathEval')
589 d like(xmlXPathObjectPtr)
590 d str * value options(*string) const xmlChar *
591 d ctx value like(xmlXPathContextPtr)
593 d xmlXPathEvalExpression...
594 d pr extproc('xmlXPathEvalExpression')
595 d like(xmlXPathObjectPtr)
596 d str * value options(*string) const xmlChar *
597 d ctxt value like(xmlXPathContextPtr)
599 d xmlXPathEvalPredicate...
600 d pr extproc('xmlXPathEvalPredicate')
602 d ctxt value like(xmlXPathContextPtr)
603 d res value like(xmlXPathObjectPtr)
605 * Separate compilation/evaluation entry points.
608 d pr extproc('xmlXPathCompile')
609 d like(xmlXPathCompExprPtr)
610 d str * value options(*string) const xmlChar *
612 d xmlXPathCtxtCompile...
613 d pr extproc('xmlXPathCtxtCompile')
614 d like(xmlXPathCompExprPtr)
615 d ctxt value like(xmlXPathContextPtr)
616 d str * value options(*string) const xmlChar *
618 d xmlXPathCompiledEval...
619 d pr extproc('xmlXPathCompiledEval')
620 d like(xmlXPathObjectPtr)
621 d comp value like(xmlXPathCompExprPtr)
622 d ctx value like(xmlXPathContextPtr)
624 d xmlXPathCompiledEvalToBoolean...
626 d 'xmlXPathCompiledEvalToBoolean')
628 d comp value like(xmlXPathCompExprPtr)
629 d ctxt value like(xmlXPathContextPtr)
631 d xmlXPathFreeCompExpr...
632 d pr extproc('xmlXPathFreeCompExpr')
633 d comp value like(xmlXPathCompExprPtr)
634 /endif LIBXML_XPATH_ENABLED
636 /undefine XML_TESTVAL
637 /if defined(LIBXML_XPATH_ENABLED)
639 /elseif defined(LIBXML_SCHEMAS_ENABLED)
642 /if defined(XML_TESTVAL)
643 d xmlXPathInit pr extproc('xmlXPathInit')
645 d xmlXPathIsNaN pr extproc('xmlXPathIsNaN')
647 d val value like(xmlCdouble)
649 d xmlXPathIsInf pr extproc('xmlXPathIsInf')
651 d val value like(xmlCdouble)
653 /undefine XML_TESTVAL
656 * C macros implemented as procedures for ILE/RPG support.
658 /if defined(LIBXML_XPATH_ENABLED)
659 d xmlXPathNodeSetGetLength...
660 d pr extproc('__xmlXPathNodeSetGetLength')
662 d ns value like(xmlNodeSetPtr)
664 d xmlXPathNodeSetItem...
665 d pr extproc('__xmlXPathNodeSetItem')
667 d ns value like(xmlNodeSetPtr)
668 d index value like(xmlCint)
670 d xmlXPathNodeSetIsEmpty...
671 d pr extproc('__xmlXPathNodeSetIsEmpty')
673 d ns value like(xmlNodeSetPtr)
674 /endif LIBXML_XPATH_ENABLED