From 34bef0cbf920d0208fd04f17fafe8c8fd355efb2 Mon Sep 17 00:00:00 2001 From: dsiders Date: Sat, 18 Sep 2021 19:37:34 +0100 Subject: [PATCH] Docs: LazUtils/laz2_xpath. Adds or updates topic content. --- docs/xml/lazutils/laz2_xpath.xml | 545 +++++-------------------------- 1 file changed, 82 insertions(+), 463 deletions(-) diff --git a/docs/xml/lazutils/laz2_xpath.xml b/docs/xml/lazutils/laz2_xpath.xml index 391afa60b3..206f633d9f 100644 --- a/docs/xml/lazutils/laz2_xpath.xml +++ b/docs/xml/lazutils/laz2_xpath.xml @@ -12,7 +12,7 @@

- laz2_xpath.pas provides an implementation of the XML Path Language (XPath) for Free Pascal. It is based on the xpath.pp unit from the Free Component Library (FCL). + laz2_xpath.pas provides an implementation of the XML Path Language (XPath) for the Lazarus IDE. It is based on the xpath.pp unit from the Free Component Library (FCL).

Copyright (c) 2000 - 2003 by Areca Systems GmbH / Sebastian Guenther, sg@freepascal.org @@ -22,17 +22,21 @@

- XML Path Language (XPath) Version 1.0 - W3C Recommendation 16 November 1999 + XML Path Language (XPath) Version 1.0, + W3C Recommendation, + 16 November 1999

+

+ This file is part of the LazUtils package. +

- - - + + + @@ -139,8 +143,6 @@ - - No axis specified. @@ -318,23 +320,16 @@ - - Boolean result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. - Specifies the method used to evaluate an XPath Predicate Expression. @@ -346,18 +341,12 @@ - - Contains the result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. @@ -378,10 +367,10 @@ - Represents an XPath Literal expression. + Represents an XPath literal expression.

- TXPathConstantNode is a TXPathExprNode descendant that represents an XPath predicate expression which contains a Literal value (any value surrounded by Quotation Marks). The return value is the TXPathVariable passed to the constructor for the class instance. + TXPathConstantNode is a TXPathExprNode descendant that represents an XPath predicate expression which contains a literal value (any value surrounded by Quotation Marks). The return value is the TXPathVariable passed to the constructor for the class instance.

@@ -399,8 +388,6 @@
- - XPath variable with the value for the literal expression. @@ -415,30 +402,28 @@ - Evaluates the XPath expression using the context node and environment. + Returns the value for the constant node and increments its reference count. - + +

+ The context node and the XPath environment arguments are not used in the method. +

+
- - - Result for the evaluated expression. + Value for the constant node. - - Context node for the evaluation. - - XPath environment for the evaluation. - Represents an XPath Variable expression. + Represents an XPath variable expression.

TXPathVariableNode is a TXPathExprNode descendant that represents an XPath Variable Reference expression in the XPath syntax. For example: @@ -463,8 +448,6 @@ - - Name for the variable. @@ -489,18 +472,12 @@ - - Result for the evaluated expression. - - Context node for the function. - - XPath environment for the evaluation. @@ -533,15 +510,11 @@ - - - Name of the function. + Name of the XPath function represented by the class instance. - - - Arguments passed to the function. + TXPathNodeArray instance with the arguments passed to the function. @@ -553,7 +526,9 @@ - Evaluates the XPath expression. + + Evaluates the XPath function name using the specified context and environment. +

Evaluate is an overridden TXPathVariable function that implements the method defined in the ancestor class. Evaluate is used to derive the value for the function call using any arguments found in the XPath expression, and to store the result in the TXPathVariable return value. @@ -573,18 +548,12 @@ - - - Result for the evaluated expression. + Result for the evaluated function. - - - Context node for the expression. + Context node for the evaluation. - - XPath environment for the evaluation. @@ -615,8 +584,6 @@ - - Operand in the XPath expression. @@ -645,25 +612,19 @@ - - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. - The base class for Binary Operations. + The base class for XPath expressions which represent Binary operations. @@ -681,12 +642,16 @@ - Identifies Math Operators used in XPath expressions. - - + Identifies the binary Math Operators used in XPath expressions. + +

+ Used in the implementation of the TXPathMathOpNode class. +

+
+ + +
- - The Addition (+) operator. @@ -725,18 +690,12 @@
- - Math operator used in the XPath expression. - - Left hand Operand. - - Right hand Operand. @@ -747,30 +706,28 @@
- - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. - Identifies a Comparison operator used in an XPath expression. - - + Identifies Comparison operators used in an XPath expression. + +

+ Used in the implementation of the TXPathCompareNode class. +

+
+ + +
- - The Equality (=) operator. @@ -813,18 +770,12 @@
- - Operator for the comparison. - - Left hand Operand. - - Right hand Operand. @@ -835,18 +786,12 @@
- - Result for the comparison. - - Context node for the expression. - - XPath environment for the evaluation. @@ -886,18 +831,12 @@
- - Operator for the Boolean expression. - - Left hand operand. - - Right hand operand. @@ -908,18 +847,12 @@
- - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. @@ -945,13 +878,9 @@
- - Left hand operand. - - Right hand operand. @@ -962,18 +891,12 @@ - - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. @@ -1031,8 +954,6 @@ - - XPath Expression to use in the class instance. @@ -1050,18 +971,12 @@ - - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. @@ -1072,8 +987,6 @@ - - An invalid Axis name in the XPath syntax. @@ -1168,13 +1081,9 @@ - - Context node for the Location Step. - - Node Set for the evaluated expression. @@ -1213,13 +1122,9 @@ - - Axis type to use for the Location Step. - - Node Test Type to use for the Location Step. @@ -1230,18 +1135,12 @@ - - Result for the evaluated expression. - - Context node for the expression. - - XPath environment for the evaluation. @@ -1263,13 +1162,9 @@ - - Message for the evaluation error. - - Arguments used to format the message for the evaluation error. @@ -1297,13 +1192,9 @@ - - Message for the error. - - Arguments used to format the message for the error. @@ -1314,8 +1205,6 @@ - - Value for TypeName. @@ -1333,8 +1222,6 @@ - - Value for the variable as a Node Set. @@ -1345,8 +1232,6 @@ - - Value for the variable as a Boolean data type. @@ -1357,8 +1242,6 @@ - - Value for the variable as a Numeric data type. @@ -1369,8 +1252,6 @@ - - Value for the variable as a String data type. @@ -1398,8 +1279,6 @@ - - Value for the Node Set variable. @@ -1417,8 +1296,6 @@ - - Value for the Node Type name. @@ -1429,8 +1306,6 @@ - - Value for the Node Set variable as a Node Set type. @@ -1441,8 +1316,6 @@ - - Value for the Node Set variable as a String data type. @@ -1455,8 +1328,6 @@ - - Value for the Node Set variable as a Boolean data type. @@ -1467,8 +1338,6 @@ - - Value for the Node Set variable as a Numeric data type. @@ -1496,8 +1365,6 @@ - - Initial value for the variable. @@ -1508,8 +1375,6 @@ - - The value for TypeName. @@ -1520,8 +1385,6 @@ - - Boolean value for the variable. @@ -1532,8 +1395,6 @@ - - Numeric value for the variable. @@ -1544,8 +1405,6 @@ - - String value for the variable. @@ -1573,8 +1432,6 @@ - - Initial value for the variable. @@ -1585,8 +1442,6 @@ - - Value for TypeName. @@ -1597,8 +1452,6 @@ - - Boolean value for the variable. @@ -1609,8 +1462,6 @@ - - Numeric value for the variable. @@ -1621,8 +1472,6 @@ - - String value for the variable. @@ -1650,8 +1499,6 @@ - - Initial value for the variable. @@ -1662,8 +1509,6 @@ - - Value for TypeName. @@ -1674,8 +1519,6 @@ - - Boolean value for the variable. @@ -1686,8 +1529,6 @@ - - Numeric value for the variable. @@ -1698,8 +1539,6 @@ - - String value for the variable. @@ -1836,8 +1675,6 @@ - - Primary expression parsed in the method. @@ -1848,8 +1685,6 @@ - - Function call parsed in the method. @@ -1860,8 +1695,6 @@ - - Union expression parsed in the method. @@ -1872,8 +1705,6 @@ - - Path expression parsed in the method. @@ -1884,20 +1715,16 @@ - - Filter expression parsed in the method. - Parses an Or Expression in the XPath expression. + Parses an Or expression in the XPath expression. - - Or expression parsed in the method. @@ -1908,8 +1735,6 @@ - - And expression parsed in the method. @@ -1920,8 +1745,6 @@ - - Equality expression parsed in the method. @@ -1932,8 +1755,6 @@ - - Relational expression parsed in the method. @@ -1944,8 +1765,6 @@ - - Additive expression parsed in the method. @@ -1956,8 +1775,6 @@ - - Multiplicative expression parsed in the method. @@ -1968,8 +1785,6 @@ - - Unary expression parsed in the method. @@ -1980,8 +1795,6 @@ - - Lexical token read in the scanner. @@ -1992,8 +1805,6 @@ - - False if the token does not contain a valid QName. @@ -2004,8 +1815,6 @@ - - XPath expression examined in the scanner/parser. @@ -2016,8 +1825,6 @@ - - Token kind located in the method. @@ -2028,8 +1835,6 @@ - - Value for the pending logical token in the scanner. @@ -2040,13 +1845,9 @@ - - True if the current token is the same as the tok argument. - - Token expected in the method. @@ -2099,18 +1900,12 @@ - - Context node for the expression. - - Position in the context node. - - Size (or length) of the context node set. @@ -2128,8 +1923,6 @@ - - XPath variable returned from the XPath function implementation. @@ -2170,8 +1963,6 @@ TXPathEnvironment.FunctionCount - - Value for the FunctionCount property. @@ -2180,11 +1971,9 @@ Gets the value for the VariableCount property. - TXPathEnvironment.VariableCount + TXPathEnvironment.VariableCount - - Value for the VariableCount property. @@ -2195,18 +1984,12 @@ - - XPath function with the specified name or ordinal position. - - Ordinal position for the requested function. - - Name for the requested function. @@ -2217,18 +2000,12 @@ - - XPath variable with the specified name or ordinal position. - - Ordinal position for the requested variable. - - Name for the requested variable. @@ -2239,8 +2016,6 @@ - - Variable returned by the XPath function. @@ -2249,8 +2024,6 @@ Context node for the function. - - Arguments for the function. @@ -2263,18 +2036,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2287,18 +2054,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2311,18 +2072,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2335,18 +2090,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2359,18 +2108,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2383,18 +2126,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2407,18 +2144,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2431,18 +2162,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2455,18 +2180,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2479,18 +2198,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2503,18 +2216,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2527,18 +2234,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2551,18 +2252,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2575,18 +2270,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2599,18 +2288,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2623,18 +2306,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2647,18 +2324,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2671,18 +2342,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2695,18 +2360,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2719,18 +2378,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2743,18 +2396,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2767,18 +2414,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2791,18 +2432,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2815,18 +2450,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2839,18 +2468,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2863,18 +2486,12 @@ - - Variable returned by the XPath function. - - Context node for the function. - - Arguments for the function. @@ -2901,15 +2518,11 @@ - - Ordinal position of the XPath function with the specified name. - - Name of the XPath function to locate in the Functions property. @@ -2924,15 +2537,11 @@ - - Ordinal position of the variable with the specified name. - - Name of the variable to locate in the Variables property. @@ -2947,15 +2556,11 @@ - - Name for the function added to the Functions property. - - Function implementation to use for the specified function name. @@ -2970,15 +2575,11 @@ - - Name of the variable added in the method. - - Value for the variable added in the method. @@ -2993,15 +2594,11 @@ - - Ordinal position for the Function with the specified name. - - Name of the function to remove from the Functions property. @@ -3014,15 +2611,11 @@ - - Ordinal position for the variable to remove from the XPath environment. - - Name of the variable to remove from the XPath environment. @@ -3049,8 +2642,6 @@ - - Ordinal position for the requested XPath function. @@ -3060,7 +2651,6 @@ - Name for the requested XPath function. @@ -3071,7 +2661,6 @@ - Ordinal position for the requested variable. @@ -3097,7 +2686,14 @@ Constructor for the class instance. - + +

+ Create is the constructor for the class instance, and calls the inherited method on entry. Create uses AResolver as the value for the Resolver property in AScanner. It also updates the internal root node for the expression retrieved by calling the ParseOrExpr method in AScanner. +

+

+ Create raises an EXPathEvaluationError exception if the scanner contains unused token after evaluating the XPath expression and the CompleteExpression argument is set to True. +

+
@@ -3118,7 +2714,7 @@ - Evaluates an XPath expression using the specified context node and environment. + Evaluates an XPath expression using the scanner for the class instance with the specified context node and environment. @@ -3136,9 +2732,32 @@ - Evaluates an XPath expression using the specified context node and resolver. + Evaluates an XPath expression using the specified context node and optional namespace resolver. - + +

+ EvaluateXPathExpression is a TXPathVariable function used to locate and return a node or tree of nodes that match the XPath expression specified in AExpressionString. AExpressionString is similar to a SQL query, and is used to navigate and select DOM nodes found in the AContextNode argument. XPath syntax is defined in the specification located at: +

+

+ + XML Path Language (XPath) Version 1.0, + W3C Recommendation, + 16 November 1999 + +

+

+ AContextNode is a DOM node in an existing XML document, and provides the node tree searched in the routine. It may be be the root element in an XML document, but may also contain one the child nodes in a document to perform a limited search. +

+

+ AResolver is a TXPathNSResolver instance which allows namespace prefixes and URLs to be validated while evaluating the XPath expression. It is an optional argument (the default value is Nil), and when omitted causes only the namespaces defined in AContextNode to be considered valid. The resolver instance must be created (when needed) using a DOM node which contains the namespace declarations for node prefixes that can be included in the XPath expression, and the nodes in the result set. +

+

+ EvaluateXPathExpression creates a TXPathScanner instance used to parse and process the XPath expression, and to compare DOM nodes for inclusion in a result set. It is passed as an argument a TXPathExpression instance also created in the routine, and used to build the DOM tree that is the return value for the function. The evaluator is configured to perform a complete evaluation of the XPath expression, including phrases which are non-deterministic. It also returns the TXPathVariable instance with the DOM node(s) which match the evaluated expression. +

+

+ The TXPathVariable return value may be cast to a type expected in the application using methods like AsNodeSet, AsBoolean, or AsText. It may also be cast to a specific class type like TXPathNodeSetVariable, TXPathBooleanVariable, TXPathNumberVariable, or TXPathStringVariable. +

+