Common Lisp Package: XPATH

Plexippus XPath is an XPath 1.0 implementation for Common Lisp. @begin[Using XPath]{section} Almost all uses of XPath involve the @code{evaluate} function, which can parse, compile, and invoke XPath expressions. @aboutfun{evaluate} @aboutmacro{xpath} @end{section} @begin[Compiling XPath dynamically]{section} @code{compile-xpath} allows the compilation of XPath into a closure ahead of time, so that @code{evaluate} only needs to invoke that closure rather than having to re-compile it first. Although @code{evaluate} itself already performs caching of compiled closures, explicit precompilation can aid optimizations if one call site uses multiple XPath expressions. Explicit compilation using @code{compile-xpath} is also required when using custom environment classes, since @code{evaluate} compiles expressions using the dynamic environment only. @code{parse-xpath} can be used to translate the standard string representation of XPath into a Plexippus-specific sexp representation. Both @code{compile-xpath} and @code{evaluate} accept sexps instead of strings. @aboutfun{parse-xpath} @aboutfun{compile-xpath} @end{section} @begin[Type coercion]{section} These correspond to the XPath functions boolean(), string(), and number(). In addition, @code{node-set-value} is provided, which turns nodes into node sets. @aboutfun{boolean-value} @aboutfun{string-value} @aboutfun{number-value} @aboutfun{node-set-value} @end{section} @begin[The dynamic environment]{section} The default enviroment used by @code{evaluate} is the dynamic environment, backed by information bound in dynamic variables. The following macros are used to bind these variables. They have dynamic scope. (The dynamic environment is currently not capable of dynamic declarations for variables, but can be used with extension functions that are declared globally.) (The XPATH-SYS defined an @a[xpath-sys.html]{environment protocol} for user-defined environment classes.) @aboutmacro{with-namespaces} @aboutmacro{with-variables} @end{section} @begin[The run-time context]{section} Instead of passing a node to @code{evaluate}, user code can construct a full context object. The context object specifies values to be returned by position(), current(), and last(). @aboutclass{context} @aboutfun{make-context} @aboutfun{context-node} @aboutfun{context-starting-node} @aboutfun{context-position} @aboutfun{context-size} @end{section} @begin[Node sets]{section} Node sets are the XPath data type used to represent the results of evaluations that select multiple nodes. As sets, they never contain duplicates. In addition to the high-level functions defined here, the XPATH-SYS package defined several @a[xpath-sys.html]{low-level node set functions}. Please also refer to the description there for details on node set order. @aboutfun{first-node} @aboutfun{all-nodes} @aboutfun{map-node-set} @aboutfun{map-node-set->list} @aboutmacro{do-node-set} @aboutfun{make-node-set-iterator} @aboutfun{node-set-iterator-end-p} @aboutfun{node-set-iterator-next} @aboutfun{node-set-iterator-current} @aboutfun{node-set-p} @aboutfun{node-set-empty-p} @aboutfun{node-set} @aboutfun{list->node-set} @aboutfun{sort-node-set} @end{section} @begin[Miscellaneous]{section} Other useful functions, variables, and classes: @aboutmacro{with-plx-extensions} @aboutvar{*navigator*} @aboutclass{xpath-error} @end{section}

README:

FUNCTION

Public

ALL-NODES (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a list of nodes} Returns all nodes of the @code{node-set} as a list.

BOOLEAN-VALUE (VALUE)

@arg[value]{value of an XPath-supported type or an XML node} @return{an XPath boolean} @short{Returns the value of XPath boolean() function.} For XML nodes returns the value of XPath boolean() function applied to the result of calling @fun{string-value} for the specified @code{value}.

COMPILE-XPATH (XPATH &OPTIONAL (ENVIRONMENT (MAKE-DYNAMIC-ENVIRONMENT *DYNAMIC-NAMESPACES*)))

@arg[xpath]{an XPath expression} @return{a compiled XPath expression} @short{Compiles an XPath expression} The @code{xpath} expression is compiled using current environment if it isn't compiled yet. @code{xpath} can be a string, a sexpr-based XPath epression or a compiled expression. In the latter case @code{xpath} argument value itself is returned.

CONTEXT-NODE (CONTEXT)

@arg[context]{an XPath context} @return{an XML node} Returns the context node of the XPath @code{context}.

SETFCONTEXT-NODE (NODE CONTEXT)

@arg[node]{an XML node} @arg[context]{an XPath context} @return{the @code{node}} Sets the context node of @code{context} and returns that node.

CONTEXT-POSITION (CONTEXT)

@arg[context]{an XPath context} @return{a positive integer} Returns the current position of the XPath @code{context}.

SETFCONTEXT-POSITION (POSITION CONTEXT)

@arg[position]{context position, a positive integer} @arg[context]{an XPath context} @return{the value of @code{position}} Sets the position of the XPath @code{context} and returns it.

CONTEXT-SIZE (CONTEXT)

@arg[context]{an XPath context} @return{a non-negative number} @short{Returns the size of @code{context}} If the context size was specified as a function, the result of calling that function is returned.

SETFCONTEXT-SIZE (SIZE CONTEXT)

@arg[size]{context size, a non-negative integer or a function without arguments returning non-negative integer} @arg[context]{an XPath context} @return{the value of @code{size}} Sets the size of the XPath @code{context} and returns it.

CONTEXT-STARTING-NODE (CONTEXT)

@arg[context]{an XPath context} @return{an XML node} Returns the node for which the whole XPath expression is evaluated.

SETFCONTEXT-STARTING-NODE (NODE CONTEXT)

@arg[context]{an XPath context} @return{the value of @code{node}} Sets the node which is considered "starting" one, i.e. for which the whole XPath extension is evaluated.

EVALUATE (XPATH CONTEXT &OPTIONAL UNORDERED-P)

@arg[xpath]{an XPath expression} @arg[context]{an XPath context} @arg[unordered-p]{specify true to get unordered node-set} @return{the result of evaluating @code{xpath} within the @code{context}} @short{Evaluates an XPath expression} @code{xpath} can be a string, a sexpr-based XPath epression or a compiled expression. The @code{context} can be obtained using @fun{make-context}. As an alternative, a node can be specifed. If @code{unordered-p} is false (default) and value being returned is a @class{node-set}, it will be sorted using @fun{sort-node-set} so its nodes will be in document order. If @code{unordered-p} is true, the order of the nodes is unspecified. Unordered mode can be significantly faster in some cases (and never slower).

EVALUATE-COMPILED (COMPILED-XPATH CONTEXT &OPTIONAL UNORDERED-P)

@arg[compiled-xpath]{a compiled XPath expression} @arg[context]{an XPath context} @arg[unordered-p]{specify true to get unordered node-set} @return{the result of evaluating @code{compiled-xpath} within the @code{context}} @short{Evaluates a compiled XPath expression returned by @fun{compile-xpath}} The @code{context} can be obtained using @fun{make-context}. As an alternative, a node can be specifed. If @code{unordered-p} is false (default) and value being returned is a @class{node-set}, it will be sorted using @fun{sort-node-set} so its nodes will be in document order. If @code{unordered-p} is true, the order of the nodes is unspecified. Unordered mode can be significantly faster in some cases (and never slower).

FIRST-NODE (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a @class{node-set} or nil} Returns the first node in the @code{node-set} or nil if it's empty.

LIST->NODE-SET (LIST)

@arg[list]{a list of nodes} @return{a @class{node-set}} Makes a @class{node-set} from the @code{list} of nodes.

MAKE-CONTEXT (NODE &OPTIONAL (SIZE 1) (POSITION 1) (STARTING-NODE NODE))

@arg[node]{an XML node} @arg[size]{context size, a non-negative integer or a function without arguments returning non-negative integer} @arg[position]{context position, a positive integer} Makes a @class{context} object.

MAKE-NODE-SET-ITERATOR (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a node-set iterator} @short{Creates a node set iterator for @code{node-set}} Node set iterators can be used to iterate over node-sets. This can be done without causing the XPath engine to find out all their nodes and using non-local exits.

MAP-NODE-SET (FUNC NODE-SET)

@arg[func]{a function} @arg[node-set]{a @class{node-set}} @return{nil} @short{Calls @code{func} for each node in @code{node-set}} The operation is performed lazily, i.e. if it's terminated via a non-local exit it doesn't necessarily cause the XPath engine to find out all nodes in the @class{node-set} internally.

MAP-NODE-SET->LIST (FUNC NODE-SET)

@arg[func]{a function} @arg[node-set]{a @class{node-set}} @return{a list} @short{Calls @code{func} for each node in @code{node-set} and conses up a list of its return values} The operation is performed lazily, i.e. if it's terminated via a non-local exit it doesn't necessarily cause the XPath engine to find out all nodes in the @class{node-set} internally.

NODE-SET-EMPTY-P (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a generalized boolean} Returns true if @code{node-set} is empty

NODE-SET-ITERATOR-CURRENT (ITERATOR)

@arg[iterator]{a node-set iterator returned by @fun{make-node-set-iterator}} @return{a node or nil} Returns current node of @code{iterator} or nil if it's at the end of its node set.

NODE-SET-ITERATOR-END-P (ITERATOR)

@arg[iterator]{a node-set iterator returned by @fun{make-node-set-iterator}} @return{a generalized boolean} Returns true if @code{iterator} points to the end of its node set

NODE-SET-ITERATOR-NEXT (ITERATOR)

@arg[iterator]{a node-set iterator returned by @fun{make-node-set-iterator}} @return{the value of @code{iterator}} Advances @code{iterator} if it's not at the end of its node set, does nothing otherwise.

NODE-SET-P (OBJECT)

@arg[object]{a value of any type} @return{a generalized boolean} Returns true if @code{object} is a @class{node-set}

NODE-SET-VALUE (VALUE)

@arg[value]{value of an XPath-supported type or an XML node} @return{a @class{node-set}} @short{Returns the value of XPath node-set() function.} For XML nodes returns a @class{node-set} consisting of the single node specified by @code{value}.

NUMBER-VALUE (VALUE)

@arg[value]{value of an XPath-supported type or an XML node} @return{an XPath number} @short{Returns the value of XPath number() function.} For XML nodes returns the value of XPath number() function applied to the result of calling @fun{string-value} for the specified @code{value}.

PARSE-XPATH (STR)

@arg[str]{a string} @return{a s-expression-based XPath expression} Parses a string-based XPath expression into s-expression-based one.

SORT-NODE-SET (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a sorted version of @code{node-set}} Sorts the @code{node-set} according to document order.

STRING-VALUE (VALUE)

@arg[value]{value of an XPath-supported type or an XML node} @return{an XPath string} @short{Returns the value of XPath number() function.} For XML nodes returns the value of @fun{xpath-protocol:node-text} applied to the specified @code{value}.

XPATH-ERROR (FMT &REST ARGS)

@arg[fmt]{format control string} @arg[args]{format arguments} Signals the @class{xpath-error} condition with specified message.

Private

CONCAT (&REST VALUES)

Concatenate string representations (PRINC-TO-STRING) of VALUES

DISABLE-PROFILING

@return{nil} @short{Disables profiling.} Disables profiling for future XPath compilations, but keeps recorded profiling samples for @fun{report}. Previously returned closures that were created with profiling enabled will not record samples until profiling is re-activated. @see{enable-profiling}

DOM-NAMESPACE-PARENT (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DOM-NAMESPACE-PREFIX (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DOM-NAMESPACE-URI (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

DYNAMIC-ENVIRONMENT-NAMESPACES (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

ENABLE-PROFILING (&OPTIONAL (VERBOSEP T))

@return{nil} @short{Enables profiling.} Resets any existing profile samples and enables profiling for future XPath compilations. Previously returned closures that were created with profiling disabled are not affected by this setting, but closures created during an earlier profiling session will start sampling again. But note that @fun{evaluate}, @fun{node-matches-p}, and @fun{pattern-case} will recompile their cached closure when this setting has changed. Profiling is not thread safe. @see{disable-profiling} @see{report}

ENUMERATE (PIPE &KEY COUNT KEY (RESULT PIPE))

@arg[pipe]{a pipe} @arg[count]{a non-negative integer} @arg[key]{a function} @arg[result]{an object} @return{the value of @key{result} (the value of @code{pipe} by default)} Goes through all or @code{count} elements of pipe, possibly applying the @code{key} function.

EXTENSION-DOCUMENTATION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

EXTENSION-FUNCTIONS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

EXTENSION-URI (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

FIND-XPATH-FUNCTION (LOCAL-NAME URI)

@arg[local-name]{local part of the function name} @arg[uri]{namespace URI of the function} @return[uri]{an XPath function object} @short{Performs an XPath function lookup using standard lookup rules} All defined extensions for the namespace specified by @code{uri} are scanned for function with specified @code{local-name}.

GET-NODE-ID (NODE-OR-NODE-SET)

@arg[node-or-node-set]{a @class{node-set} or a single XML node} @return{an alphanumeric string} @short{Generates an unique identifier for the first node @code{node-set} (or, if a node is specified, for that node).} This function is similar to the generate-id() XSLT function, but its results are unique only within its document, whereas XSLT also prepends an ID designating the document.

HYPSYM (&REST PARTS)

Assemble a symbol from PARTS interleaving them with hyphens

MAKE-NODE-SET (PIPE &OPTIONAL (ORDERING UNORDERED))

@arg[pipe]{a pipe} @arg[ordering]{one of :document-order, :reverse-document-order, :unordered} @return{a @class{node-set}} Makes a @class{node-set} containing nodes from the @code{pipe} with specified @code{ordering}.

MAP-PIPE-FILTERING (FN PIPE &OPTIONAL FILTER-TEST)

Map fn over pipe, delaying all but the first fn call, collecting results

MAPPEND-PIPE (FN PIPE)

lazily map fn over pipe, appending results

MAPPEND-PIPE-FILTERING (FN PIPE &OPTIONAL FILTER-TEST)

Map fn over pipe, delaying all but the first fn call, appending results, filtering along the way

MAYBE-PROGN (BODY)

Wrap the BODY with PROGN if it contains more than one form. Otherwise return the first form or NIL if the body is empty

NODE-SET-ITERATOR-PIPE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

NODE< (A B)

Compare nodes according to document order.

PATTERN-EXPRESSION (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

PATTERN-KEY (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

PATTERN-THUNK (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

PIPE-HEAD (PIPE)

@arg[pipe]{a pipe} @return{an object} Returns the head of the @code{pipe}.

PIPE-OF (NODE-SET)

@arg[node-set]{a @class{node-set}} @return{a pipe} Returns the pipe that contains the elements of the @code{node-set}.

SETFPIPE-OF (PIPE NODE-SET)

@arg[pipe]{a pipe} @arg[node-set]{a @class{node-set}} @return{the value of @code{pipe}} Sets the pipe that contains the element sof the @code{node-set}.

PIPE-TAIL (PIPE)

@arg[pipe]{a pipe} @return{an object} @short{Returns the tail of the list.} First time @code{pipe-tail} is called it causes pipe tail expression to be evaluated and remembered for later calls.

PROPER-LIST-P (LIST)

True if the LIST is proper list

REPORT (&KEY (GROUP-IDENTICAL-EXPRESSIONS T))

@arg[group-identical-expressions]{Boolean, indicates whether times recorded for closures that were compiled separately, but for the same expression, are to be summed together. Default is T.} @short{Shows profiling output.} Shows cumulative run time and real time, number of calls, and average run time for each XPath expression or XPattern matcher that was invoked. @see{enable-profiling} @see{disable-profiling}

STRING-REPLACE (STRING SUBSTRING REPLACEMENT)

Replace occurences of SUBSTRING in STRING with REPLACEMENT.

XPATH-FUNCTION-COMPILER (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

XPATH-FUNCTION-MAX-ARGS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

XPATH-FUNCTION-MIN-ARGS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

XPATH-FUNCTION-NAME (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

Undocumented

%APPEND-PIPES (PIPEX PIPEY-FUN)

%COMPILE-SUBPATTERN (SUBPATTERN ENVIRONMENT)

%DEFINE-EXTENSION (NAME URI DOCUMENTATION)

%MAKE-NODE-SET-ITERATOR (PIPE)

%MAKE-PATTERN (KEY THUNK PRIORITY VALUE EXPRESSION)

%NAMESPACE-BINDING-PAIR (PREFIX URI)

%VARIABLE-BINDING-PAIR (QNAME VALUE)

ADD-XPATH-FUNCTION (EXT NAME FUNC ARGLIST)

ARG-COUNT (ARGLIST)

AXIS-ANCESTOR (NODE)

AXIS-ANCESTOR-OR-SELF (NODE)

AXIS-ATTRIBUTE (NODE)

AXIS-CHILD (NODE)

AXIS-DESCENDANT (NODE)

AXIS-DESCENDANT-OR-SELF (NODE)

AXIS-FOLLOWING (NODE)

AXIS-FOLLOWING-SIBLING (NODE)

AXIS-FUNCTION (AXIS)

AXIS-NAMESPACE (NODE)

AXIS-PARENT (NODE)

AXIS-PRECEDING (NODE)

AXIS-PRECEDING-SIBLING (NODE)

AXIS-PRINCIPAL-NODE-TYPE (AXIS)

AXIS-PROPERTIES (AXIS)

AXIS-REVERSE-DESCENDANT-OR-SELF (NODE)

AXIS-ROOT (NODE)

AXIS-SELF (NODE)

COMPARE-NODE-SETS (OP A B)

COMPARE-NUMBERS (OP A B)

COMPARE-VALUES (OP A B)

COMPARE-WITH-NODE-SET (OP NODE-SET VALUE)

COMPARE/NO-NODE-SETS (OP A B)

COMPILE-FILTER-PATH (FILTER PREDICATE PATH ENVIRONMENT)

COMPILE-LOCATION-STEP (STEP-SPEC ENVIRONMENT)

COMPILE-NODE-TEST (NODE-TEST ENVIRONMENT ATTRIBUTEP)

COMPILE-PATH (PATH ENVIRONMENT)

COMPILE-PATTERN-EXPRESSION (PATTERN ENVIRONMENT)

COMPILE-PATTERN-EXPRESSION/SEXPR (PATTERN ENVIRONMENT)

COMPILE-PREDICATES (PREDICATES ENVIRONMENT)

COMPILE-SUBPATTERN (SUBPATTERN ENVIRONMENT)

COMPILE-VARIABLE (NAME ENVIRONMENT)

COMPILE-XPATH-FUNCTION-CALL (XPATH-FUNCTION ARGUMENT-THUNKS)

COMPILE-XPATH/SEXPR (EXPR ENVIRONMENT)

COPY-DOM-NAMESPACE (INSTANCE)

COPY-DYNAMIC-ENVIRONMENT (INSTANCE)

COPY-ENVIRONMENT (INSTANCE)

COPY-EXTENSION (INSTANCE)

COPY-NODE-SET-ITERATOR (INSTANCE)

COPY-PATTERN (INSTANCE)

COPY-TEST-ENVIRONMENT (INSTANCE)

COPY-XPATH-FUNCTION (INSTANCE)

DECODE-DYNAMIC-QNAME (QNAME)

DECODE-QNAME (QNAME ENVIRONMENT ATTRIBUTEP)

DOM-NAMESPACE-P (OBJECT)

SETFDOM-NAMESPACE-PARENT (NEW-VALUE INSTANCE)

SETFDOM-NAMESPACE-PREFIX (NEW-VALUE INSTANCE)

SETFDOM-NAMESPACE-URI (NEW-VALUE INSTANCE)

DRIBBLE-TESTS

SETFDYNAMIC-ENVIRONMENT-NAMESPACES (NEW-VALUE INSTANCE)

DYNAMIC-ENVIRONMENT-P (OBJECT)

ENVIRONMENT-P (OBJECT)

SETFEXTENSION-DOCUMENTATION (NEW-VALUE INSTANCE)

SETFEXTENSION-FUNCTIONS (NEW-VALUE INSTANCE)

EXTENSION-P (OBJECT)

SETFEXTENSION-URI (NEW-VALUE INSTANCE)

FILTER-PIPE (FUNCTION PIPE)

FIND-DYNAMIC-NAMESPACE (PREFIX)

FIND-IN-PIPE (ITEM PIPE &KEY (TEST #'EQUAL) (KEY #'IDENTITY))

FIND-IN-PIPE-IF (PRED PIPE &KEY (KEY #'IDENTITY))

FIND-NAMESPACE (PREFIX ENVIRONMENT ATTRIBUTEP)

FINITE-P (NUM)

FMOD (F G)

FORCE (PIPE)

GET-LANG-ATTRIBUTE (NODE)

GET-NODE-INDEX (NODE)

GET-NODE-TEXT (NODE)

GROUP-AND-SORT-SAMPLES (GROUP-IDENTICAL-EXPRESSIONS)

INF-P (NUM)

JOIN-XPATH-RESULT (RESULT)

LONG-TO-DOUBLE (L)

MAKE-DOM-NAMESPACE (PARENT PREFIX URI)

MAKE-DYNAMIC-ENVIRONMENT (NAMESPACES)

MAKE-ENVIRONMENT (&KEY)

MAKE-EXTENSION (URI DOCUMENTATION &OPTIONAL (FUNCTIONS (MAKE-HASH-TABLE TEST #'EQUAL)))

MAKE-FIXUP-LEXER (NEXT-LEXER)

MAKE-FUNCTION-NAME (X)

MAKE-LOCATION-PATH (STEPS)

MAKE-LOCATION-STEP (AXIS NODE-TEST PREDICATES ENVIRONMENT)

MAKE-REVERSE-LOCATION-PATH (STARTING-NODE-CHECK STEPS PREDICATE-CHECKS)

MAKE-REVERSE-LOCATION-STEP (STEP ENVIRONMENT)

MAKE-REVERSE-PREDICATE-CHECK (STEP ENVIRONMENT)

MAKE-TEST-ENVIRONMENT (&KEY)

MAKE-XPATH-FUNCTION (COMPILER NAME MIN-ARGS MAX-ARGS)

MAP-PIPE (FUNCTION PIPE)

MAPPEND-LAZY

MAYBE-WRAP-PROFILING (KEY FUN)

MKLIST (VALUE)

NAMEP (STR)

NAMESPACES-MATCH-P (OLD-BINDINGS CUR-BINDINGS)

NAN-P (XNUM)

NC-NAME-P (STR)

NODE-SET-ITERATOR-P (OBJECT)

SETFNODE-SET-ITERATOR-PIPE (NEW-VALUE INSTANCE)

NODE-TEST-COMMENT

NODE-TEST-NAME (LOCAL-NAME &OPTIONAL (URI ))

NODE-TEST-NAMESPACE (URI)

NODE-TEST-NODE

NODE-TEST-PRINCIPAL

NODE-TEST-PROCESSING-INSTRUCTION (&OPTIONAL NAME)

NODE-TEST-TEXT-NODE

NODE-TYPE (NODE)

PARENT-PIPE (NODE)

PARSE-XNUM (STR)

SETFPATTERN-EXPRESSION (NEW-VALUE INSTANCE)

SETFPATTERN-KEY (NEW-VALUE INSTANCE)

PATTERN-P (OBJECT)

SETFPATTERN-THUNK (NEW-VALUE INSTANCE)

PIPE-ELT (N PIPE)

PIPE-EMPTY-P (PIPE)

PIPE-LENGTH (PIPE)

PREPROCESS-NUMBER-STR (STR)

REPORT-XPATH (GROUPED-SAMPLES)

REPORT-XPATTERN (GROUPED-SAMPLES)

ROUND-TO-INTEGER (A)

RUN-ALL-TESTS

SAME-EXPR-P (PREV-EXPR XPATH CUR-BINDINGS)

SAMPLE-NODE-SET (&OPTIONAL (XML ))

SORT-NODES (PIPE)

SORT-PIPE (PIPE &OPTIONAL (ORDERING UNORDERED))

SORTED-PIPE-OF (NODE-SET)

STEP-KEY (STEP ENVIRONMENT)

STRINGIFY-PATTERN-EXPRESSION (EXPR)

STRINGIFY-PATTERN-EXPRESSIONS (PATTERNS)

SUBPATTERN-KEY (SUBPATTERN ENVIRONMENT)

SUBPIPE-AFTER (ELT PIPE &KEY (TEST #'EQL))

SUBPIPE-BEFORE (ELT PIPE &KEY (TEST #'EQL))

TEST-COMPARISON

TEST-COMPUTED-WITH-VARIABLES

TEST-EAGER-WITH-VARIABLE-EVALUATION

TEST-ENVIRONMENT-P (OBJECT)

TEST-FILTERING

TEST-FOLLOWING

TEST-LEXER (STR)

TEST-NODE-MATCHES-P

TEST-NODE-SET-API

TEST-PATTERN-CASE

TEST-PLX-EXTENSIONS

TEST-VALUES

TEST-WITH-NAMESPACES-0

TEST-WITH-NAMESPACES-1

TEST-WITH-NAMESPACES-2

TEST-WITH-NAMESPACES-3

TEST-WITH-NAMESPACES-4

TEST-WITH-VARIABLES-1

TEST-WITH-VARIABLES-2

TEST-WITH-VARIABLES-3

TEST-XMLS

TEST-XNUM

TEST-XPATH

TEXTUALLY-FIRST-NODE (NODE-SET)

TRIM (STR)

VALID-EXPRESSION-P (EXPR)

VECTOR->PIPE (VECTOR &OPTIONAL (START 0))

WRAP-PROFILING (KEY FUN)

WRITE-NODE-TEST (NODE-TEST S)

X-MINUSP (XNUM)

X-PLUSP (XNUM)

X-ZEROP (XNUM)

XF-AND (EXPRS)

XF-EQUAL (U V)

XF-LOCATION-PATH (PATH)

XF-OR (EXPRS)

XF-TRUE

XF-VALUE (X)

XFD-* (THUNKS-874)

XFD-+ (THUNKS-851)

XFD-- (THUNKS-943)

XFD-/ (THUNKS-897)

XFD-/= (THUNKS-46)

XFD-< (THUNKS-69)

XFD-<= (THUNKS-115)

XFD-= (THUNKS-23)

XFD-> (THUNKS-92)

XFD->= (THUNKS-138)

XFD-AND (THUNKS-160)

XFD-BOOLEAN (THUNKS-206)

XFD-CEILING (THUNKS-824)

XFD-CONCAT (THUNKS-559)

XFD-CONTAINS (THUNKS-581)

XFD-COUNT (THUNKS-367)

XFD-CURRENT (THUNKS-87)

XFD-FALSE (THUNKS-200)

XFD-FLOOR (THUNKS-778)

XFD-GENERATE-ID (THUNKS-93)

XFD-ID (THUNKS-518)

XFD-LANG (THUNKS-234)

XFD-LAST (THUNKS-361)

XFD-LOCAL-NAME (THUNKS-390)

XFD-MATCHES (THUNKS-13)

XFD-MOD (THUNKS-920)

XFD-NAME (THUNKS-413)

XFD-NAMESPACE-URI (THUNKS-436)

XFD-NORMALIZE-SPACE (THUNKS-722)

XFD-NOT (THUNKS-171)

XFD-NUMBER (THUNKS-767)

XFD-OR (THUNKS-165)

XFD-POSITION (THUNKS-355)

XFD-REPLACE (THUNKS-50)

XFD-ROUND (THUNKS-801)

XFD-STARTS-WITH (THUNKS-643)

XFD-STRING (THUNKS-548)

XFD-STRING-LENGTH (THUNKS-712)

XFD-SUBSTRING (THUNKS-604)

XFD-SUBSTRING-AFTER (THUNKS-690)

XFD-SUBSTRING-BEFORE (THUNKS-667)

XFD-SUM (THUNKS-493)

XFD-TRANSLATE (THUNKS-731)

XFD-TRUE (THUNKS-194)

XFD-UNION (THUNKS-459)

XNUM-* (A B)

XNUM-+ (A B)

XNUM-- (A &OPTIONAL B)

XNUM-/ (A B)

XNUM->STRING (XNUM)

XNUM-CEILING (A)

XNUM-FLOOR (A)

XNUM-MOD (F G)

XNUM-P (VALUE)

XNUM-ROUND (A)

SETFXPATH-FUNCTION-COMPILER (NEW-VALUE INSTANCE)

SETFXPATH-FUNCTION-MAX-ARGS (NEW-VALUE INSTANCE)

SETFXPATH-FUNCTION-MIN-ARGS (NEW-VALUE INSTANCE)

SETFXPATH-FUNCTION-NAME (NEW-VALUE INSTANCE)

XPATH-FUNCTION-P (OBJECT)

XPATH-LEXER (STR)

MACRO

Public

DO-NODE-SET ((VAR NODE-SET &OPTIONAL RESULT) &BODY BODY)

@arg[var]{symbol, a variable name} @arg[node-set]{a @class{node-set}} @arg[result]{a form} @return{the result of evaluating @code{result}} @short{Executes @code{body} with @code{var} bound to successive nodes in @code{node-set}} The operation is performed lazily, i.e. if it's terminated via a non-local exit it doesn't necessarily cause the XPath engine to find out all nodes in the @class{node-set} internally. Returns nil if @code{result} form isn't specified.

WITH-NAMESPACES ((&REST BINDINGS) &BODY BODY)

@arg[bindings]{bindings in the form (PREFIX VALUE). PREFIXes and VALUEs are evaluated} @return{the tresult of evaluating @code{body}} @short{Provides namespace bindings for XPath compilation} Namespace bindings are used for compilation of XPath expressions. nil is equivalent of "" prefix. Bindings provided by this macro have dynamic scope.

WITH-PLX-EXTENSIONS (&BODY BODY)

@short{Binds plx prefix to Plexippus XPath extensions namespace.} The following functions are currently available: @pre{plx:matches(string, pattern, flags?)} Returns true if @code{string} is matched by regular expression @code{pattern}, false otherwise. Optional @code{flags} specify modifiers (i, m, s). CL-PPCRE is used as regular expression engine. @pre{plx:replace(string, pattern, replacement, flags?)} Returns @code{string} with all matches of regular expression @code{pattern} replaced with @code{replacement}. Optional @code{flags} specify modifiers (i, m, s). @pre{plx:current()} Returns a @class{node-set} consisting of one node which was specifed as context node for expression evaluation. Analagous to @code{current()} function of XSLT. @pre{plx:generate-id(node-set?)} Returns an alphanumeric string that uniquely identifies the first node of the @code{node-set} (or context node if @code{node-set} isn't specified) within its document. Analagous to @code{generate-id()} of XSLT (except that the latter works across multiple documents).

WITH-VARIABLES ((&REST BINDINGS) &BODY BODY)

@arg[bindings]{bindings in the form (QNAME VALUE). QNAMEs and VALUEs are evaluated} @return{the tresult of evaluating @code{body}} @short{Provides bindings for XPath variables} Variable bindings are used for evaluation of compiled XPath expressions. Bindings provided by this macro have dynamic scope.

XPATH (FORM)

@arg[form]{a sexpr-based XPath form} @return{a list consisting of symbol XPATH and the @code{form}} This macro is used to specify sexpr-based XPath expression for @fun{evaluate}

Private

APPEND-PIPES (PIPEX PIPEY)

return a pipe that appends two pipes. The evaluation style of this macro has been chosen to be consistent with MAKE-PIPE: The first argument is evaluated eagerly; the second argument lazily.

ASSERT-EQUAL (EXPECTED ACTUAL)

Check whether two values are equal

ASSERT-FLOAT-EQUAL (EXPECTED ACTUAL)

Check whether two floating-point values are equal

DEFINE-EXTENSION (NAME URI &OPTIONAL DOCUMENTATION)

@arg[name]{the name of XPath extension (a symbol)} @arg[uri]{URI corresponding to XPath extension (a string)} @arg[documentation]{documentation string for the XPath extension} @short{Defines an XPath extension with specified @code{name} and @code{uri}.} An XPath extension is a collection of XPath functions that are defined using one of @fun{define-xpath-function/lazy}, @fun{define-xpath-function/eager} or @fun{define-xpath-function/single-type} macros. In order to use the extension, one must bind a prefix string to its @code{uri} using @fun{with-namespaces} macro. Example: @begin{pre} (defparameter *my-namespace* "http://example.net/my-xpath-extension") (xpath-sys:define-extension my-ext *my-namespace* "My Extension") (xpath-sys:define-xpath-function/single-type my-ext add-quotes string (string) (concat "\"" string "\"")) (defun get-my-quoted-string(doc) (with-namespaces (("my" *my-namespace*)) (evaluate "add-quotes(//some-element)" doc))) @end{pre}

DEFINE-XPATH-FUNCTION/EAGER (EXT NAME ARGS &BODY BODY)

@arg[ext]{name of an XPath extension (a symbol)} @arg[name]{XPath function name} @arg[args]{XPath function arguments} @short{Defines an XPath function, "eager" style.} The @code{body} is evaluated during evaluation of XPath expressions each time the function being defined is called. It's passed a list of values corresponding to XPath function arguments and should return a value of one of XPath types (string, boolean, number, node set). Example: @begin{pre} (define-xpath-function/eager my-ext join (delim node-set) (reduce (lambda (a b) (concatenate 'string a delim b)) (map-node-set->list #'string-value node-set))) @end{pre} @see{define-xpath-extension} @see{define-xpath-function/lazy} @see{define-xpath-function/single-type}

DEFINE-XPATH-FUNCTION/LAZY (EXT NAME ARGS &BODY BODY)

@arg[ext]{name of an XPath extension (a symbol)} @arg[name]{XPath function name} @arg[args]{XPath function arguments} @short{Defines an XPath function, "lazy" style.} The @code{body} is evaluated during compilation of XPath expressions each time the function being defined is referenced. It's passed a list of "thunks" corresponding to XPath function arguments and should return a new "thunk". A "thunk" is a function that takes an XPath @class{context} as argument and returns value of one of XPath types (string, boolean, number, node set). Example: @begin{pre} (define-xpath-function/lazy my-ext my-if (v if-part else-part) #'(lambda (ctx) (if (boolean-value (funcall v ctx)) (funcall if-part ctx) (funcall else-part ctx)))) @end{pre} @see{define-xpath-extension} @see{define-xpath-function/eager} @see{define-xpath-function/single-type}

DEFINE-XPATH-FUNCTION/SINGLE-TYPE (EXT NAME TYPE ARGS &BODY BODY)

@arg[ext]{name of an XPath extension (a symbol)} @arg[name]{XPath function name} @arg[args]{XPath function arguments} @short{Defines an XPath function, "eager" style with automatic type conversion.} The @code{body} is evaluated during evaluation of XPath expressions each time the function being defined is called. It's passed a list of values corresponding to XPath function arguments and should return a value of one of XPath types (string, boolean, number, node set). Argument values are automatically converted to specified XPath @code{type}. Example: @begin{pre} (xpath-sys:define-xpath-function/single-type my-ext add-quotes string (string) (concat "\"" string "\"")) @end{pre} @see{define-xpath-extension} @see{define-xpath-function/lazy} @see{define-xpath-function/eager}

MAKE-PIPE (HEAD TAIL)

@arg[head]{pipe head (evaluated)} @arg[tail]{tail expression} @return{a pipe} @short{Constructs a pipe (lazy list).} The @code{head} expression is evaluated immediatelly. The value of @code{head} will be returned by @fun{pipe-head} called for the pipe object returned by @code{make-pipe}. Evaluation of @code{tail} expression is delayed until @fun{pipe-tail} is called for the pipe returned by this function. Evaluation of @code{tail} expression should produce a pipe or a list.

WITH-GENSYMS (SYMS &REST BODY)

Execute the body binding syms to gensyms

Undocumented

%DEFINE-XPATH-FUNCTION/EAGER (EXT NAME CONVERTER ARGS &BODY BODY)

ASSERT* (&REST EXPRESSIONS)

ASSERT-EQUAL* (&REST PAIRS)

ASSERT-FLOAT-EQUAL* (&REST PAIRS)

DEFINE-AXIS (NAME (ORDERING &OPTIONAL (PRINCIPAL-NODE-TYPE ELEMENT)) &BODY BODY)

DEFINE-DEFAULT-METHOD (NAME (&REST ARGS) &BODY BODY)

DEFINE-FIXUP-LEXER (NAME &REST RULES)

DEFINE-REGEX-FUNCTION (NAME ARGS &BODY BODY)

DEFINE-XPATH-TEST (NAME &BODY BODY)

DEFLEXER (NAME-AND-OPTIONS &BODY RULES)

DEFTEST (NAME &BODY BODY)

LAMBDA* ((&REST ARGS) &BODY BODY)

ONCE-ONLY ((&REST NAMES) &BODY BODY)

VERIFY-XPATH* (XML &REST ITEMS)

WITH-CACHE ((&REST KEYS) &BODY COMPILATION-BODY)

WITH-FLOAT-TRAPS-MASKED ((&OPTIONAL) &BODY BODY)

GENERIC-FUNCTION

Private

ENVIRONMENT-FIND-FUNCTION (ENVIRONMENT LOCAL-NAME URI)

@arg[environment]{an XPath environment object} @arg[local-name]{local part of expanded-name of the function} @arg[uri]{namespace URI of the function} @return{an XPath function or nil if it cannot be found} @short{Finds an XPath function by @code{local-name} and @code{uri}}. XPath function is a Lisp function that takes zero or more "thunks" as its arguments (corresponding to XPath expressions passed as function arguments) and returns a new "thunk". A "thunk" is a function that takes an instance of @class{context} as its argument and returns the value of one of XPath types.

ENVIRONMENT-FIND-NAMESPACE (ENVIRONMENT PREFIX)

@arg[environment]{an XPath environment object} @arg[prefix]{prefix part of a QName} Returns namespace URI for specified @code{prefix}.

ENVIRONMENT-FIND-VARIABLE (ENVIRONMENT LOCAL-NAME URI)

@arg[environment]{an XPath environment object} @arg[local-name]{local part of expanded-name of the function} @arg[uri]{namespace URI of the function} @return{XPath variable "thunk"} @short{Finds an XPath variable by @code{local-name} and @code{uri}}. XPath variable is represented by a "thunk". A "thunk" is a function that takes an instance of @class{context} as its argument and returns the value of one of XPath types.

SLOT-ACCESSOR

Private

Undocumented

ORDERING-OF (OBJECT)

SETFORDERING-OF (NEW-VALUE OBJECT)

VARIABLE

Public

Undocumented

*NAVIGATOR*

Private

Undocumented

*DOCUMENT-ELEMENT*

*DOM-BUILDER*

*DYNAMIC-NAMESPACES*

*DYNAMIC-VAR-BINDINGS*

*EXTENSIONS*

*INITIAL-NAMESPACES*

*PLX-URI*

*PROFILING-ENABLED-P*

*SAMPLE-XML*

*SAMPLE-XML-2*

*SAMPLE-XML-3*

*SAMPLE-XML-4*

*SAMPLES*

*TESTS*

*XPATH-PARSER*

+NAN+

CLASS

Public

CONTEXT

Represents XPath context

NODE-SET

Represents an XPath node set @see-constructor{make-node-set}

Private

Undocumented

DOM-NAMESPACE

DYNAMIC-ENVIRONMENT

ENVIRONMENT

EXTENSION

NODE-SET-ITERATOR

TEST-ENVIRONMENT

XPATH-FUNCTION

CONDITION

Public

XPATH-ERROR (FMT &REST ARGS)

The class of all xpath errors.

CONSTANT

Private

Undocumented

EMPTY-PIPE