Overview Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers |
Unit xquery
Description
This unit contains a modern XPath / XQuery interpreter
The most important class is TXQueryEngine, which implements the interpreter, and IXQValue, which is the variant used to store the results.
The simplest way to evaluate an expression is to use the global function query .
For example, if you want to find all links on a webpage, you can do one of the following:
query('doc("http://example.org")//a')
query('"http://example.org"').retrieve().map('//a')
xqvalue('http://example.org').retrieve().map('//a')
query('doc($_1)//a', ['http://example.org'])
The first example is the simplest, the third demonstrates the functional interface of IXQValue, and the last how to use variables with query.
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
Types
PXQValue = ˆTXQValue; |
PIXQValue = ˆIXQValue; |
TXQVArray = array of IXQValue; |
TXQTermArray = array of TXQTerm; |
xqfloat = double; |
TXQValueKind = (...); |
TXQTermFlowerOrderEmpty = (...); |
TXQDefaultNamespaceKind = (...); |
TXQPropertyDotNotation = (...); |
TTreeNodeSerialization = (...); |
TXQParsingModel = (...); |
PXQEvaluationContext = ˆTXQEvaluationContext; |
TXQValueClass = class of TXQValue; |
PXQValueDateTimeData = ˆTXQValueDateTimeData; |
TXQValueInt64Class = class of TXQValueInt64; |
TXQValueFloatClass = class of TXQValueFloat; |
TXQValueDecimalClass = class of TXQValueDecimal; |
TXQValueDateTimeClass = class of TXQValueDateTime; |
TXQAnnotations = array of TXQAnnotation; |
TXSConstrainingFacetKind = (...); |
TXSConstrainingFacetWhitespace = (...); |
TXSConstrainingFacetExplicitTimeZone = (...); |
TXSCastingError = (...); |
TXSNumericSubType = (...); |
TXSStringSubType = (...); |
TXQDateTimeTruncation = (...); |
TXSSchemaVersion = (...); |
TXQBasicFunction = function (argc: SizeInt; argv: PIXQValue): IXQValue; |
TXQComplexFunction = function (const context: TXQEvaluationContext; argc: SizeInt; argv: PIXQValue): IXQValue; |
TXQBinaryOp = function (const cxt: TXQEvaluationContext; const a,b: IXQValue): IXQValue; |
PXQFunctionParameterTypes = ˆTXQFunctionParameterTypes; |
TXQContextDependency = (...); |
TXQContextDependencies = set of TXQContextDependency; |
TXQOperatorFlags = set of (xqofAssociativeSyntax, xqofCastUntypedToString,
xqofCastUntypedToDouble); |
TXQPathMatchingAxis = (...); |
TXQPathMatchingKind = (...); |
TXQPathMatchingKinds = set of TXQPathMatchingKind; |
TXQPathMatchingStepFilters = array of TXQPathMatchingStepFilter; |
TXQPathMatching = array of TXQPathMatchingStep; |
TTreeElementTypes = set of TTreeNodeType; |
TXQPathNodeConditionIteration = (...); |
TXQPathNodeConditionOption = (...); |
TXQPathNodeConditionOptions = set of TXQPathNodeConditionOption; |
PXQTerm = ˆTXQTerm; |
PXQTermVariable = ˆTXQTermVariable; |
TXQTerm_VisitAction = (...); |
TXQTerm_VisitorClass = class of TXQTerm_Visitor; |
TXQTermClass = class of TXQTerm; |
TXQTypeInformationKind = (...); |
TXQNamespaceMode = (...); |
TXQTermDefineFunctionKind = (...); |
TXQTermNodeMatcherDirect = (...); |
TXQTermNamedFunctionKind = (...); |
TXQTermFlowerSubClauseKind = (...); |
TXQTermFlowerWindowFlags = set of (xqtfwSliding , xqtfwEndOnlyWhen); |
TXQTermFlowerWindowVariableCallback = procedure (data: pointer; v: TXQTermVariable); |
TXQInternalPatternMatcherParse = function (const context: TXQStaticContext; data: string): TXQTermPatternMatcher; |
TXQInternalPatternMatcherMatch = function (template, data: TTreeNode; var context: TXQEvaluationContext; throwExceptions: boolean = false): TXQVariableChangeLog; |
TXQInternalPatternMatcherVisit = function (const template: TXQTermPatternMatcher; visitor: TXQTerm_Visitor): TXQTerm_VisitAction; |
TXQExceptionEvent = procedure (exception: EXQException) of object; |
TXQEvaluateVariableEvent = function (sender: TObject; const variable: string; var value: IXQValue): boolean of object; |
TXQDeclareExternalVariableEvent = procedure(sender: TObject; const context: TXQStaticContext; const namespaceUrl, variable: string; var value: IXQValue) of object; |
TXQDeclareExternalFunctionEvent = procedure(sender: TObject; const context: TXQStaticContext; const namespaceURL, functionName: string; var result: TXQValueFunction) of object; |
TXQImportModuleEvent = procedure (sender: TObject; const namespace: string; const at: array of string) of object; |
TXQTraceEvent = procedure (sender: TXQueryEngine; value, info: IXQValue) of object; |
TXQParseDocEvent = procedure (sender: TXQueryEngine; data, url, contenttype: string; var node: TTreeNode) of object; |
TXQFormatIntegerModifier = (...); |
TXQFormatIntegerModifiers = set of TXQFormatIntegerModifier; |
TXQFormatIntegerEvent = procedure (sender: TObject; integerNumber: BigDecimal; primaryFormat, modifierVariant, language: string; modifiers: TXQFormatIntegerModifiers; var formatted: string) of object; |
TXQDecimalFormatProperty = (...); |
TXQDebugTracingEvent = procedure (term: TXQTerm; const context: TXQEvaluationContext; argc: SizeInt; args: PIXQValue) of object; |
Constants
Variables
Description
Functions and Procedures
function xqvalue(const v: Boolean):IXQValue; inline; |
Creates an boolean IXQValue
|
function xqvalue(intentionallyUnusedParameter: TDateTime):IXQValue; inline; |
Raises an exception (to prevent xquery(TDateTime) from using xquery(float))
|
function xqvalue(sl: TStringList): IXQValue; |
Creates a sequence of strings (does *not* free the list)
|
function xqvalue(const sl: array of string): IXQValue; |
Creates a sequence of untyped strings
|
procedure xqvalueSeqSqueeze(var v: IXQValue); |
Squeezes an IXQValue (single element seq => single element, empty seq => undefined)
|
procedure xqvalueSeqSqueezed(out result: IXQValue; l: TXQVList); |
Creates an IXQValue from a list sequence (assume it FREEs the list)
|
procedure xqvalueSeqConstruct(var result: IXQValue; var seq: TXQValueSequence; const add: IXQValue); |
Adds a value to an implicit sequence list in result, i.e. you call it multiple times and the result becomes a sequence of all the add values. For the first call result and seq must be nil. The point is that it only creates a sequence if there are multiple values, and it is especially fast, if you do not expect multiple values.
|
procedure xqvalueMoveNoRefCount(const source: IXQValue; var dest: IXQValue ); inline; |
Assigns source to dest without updating ref counts This can be much faster, but will cause a crash, unless the reference count is corrected later, e.g. by xqvalueVaporize on source or dest.
|
procedure xqvalueVaporize(var dest: IXQValue); inline; |
|
function jsonStrEscape(s: string):string; |
Returns a "..." string for use in json (internally used)
|
procedure requiredArgCount(argc: sizeint; minc: sizeint; maxc: sizeint = -2); |
Escapes for an URL (internally used)
Checks the length of the args array (internally used)
|
procedure xpathRangeDefinition(argc: sizeint; args: PIXQValue; const maxLen: longint; out from, len: integer); |
Calculates starting position / length from a range definition (checks for things like NaN, INF, ...) (internally used)
|
function query(q: string; const vs: array of string): IXQValue; overload; |
Evaluates an XQuery 3 query using the defaultQueryEngine. All values in vs are available as $_1, $_2, $_3, ...
For example query ('$_1 to $_2', ['10', '100']) to get all numbers from 10 to 100. Or query ('doc($_1)//title', ['http://example.org']) to get the title of a webpage. Or query ('form(doc($_1)//form, {"q": $_2})', ['http://google.com', 'search term']).retrieve() to fill in a formular on a webpage/search something on Google.
|
function defaultQueryEngine: TXQueryEngine; |
This is a thread local global query engine. You must call freeThreadVars, after having using it from different threads. When loading additional XML/HTML documents (e.g. with doc or retrieve) they are also only freed by freeThreadVars.
|
procedure freeThreadVars; |
If you use the default query engine from different threads, you have to call freeThreadVars . before the thread terminates to prevent memory leaks This also calls freeThreadVars of internetaccess
|
function charUnicodeZero(const cp: integer): integer; |
|
procedure ignore(const intentionallyUnusedParameter: IXQValue); inline; |
|
procedure ignore(const intentionallyUnusedParameter: TObject); inline; |
|
procedure ignore(const intentionallyUnusedParameter: TXQVArray); inline; |
|
function isPosInf(const f: xqfloat): boolean; |
|
function isNegInf(const f: xqfloat): boolean; |
|
function isSignedXQFloat(const v: xqfloat): boolean; |
|
function treeElementAsString(node: TTreeNode; deepSeparator: string = ''): string; inline; deprecated 'for internal use'; |
Warning: this symbol is deprecated: for internal use |
function urlHexDecode(s: string): string; deprecated 'for internal use'; |
Warning: this symbol is deprecated: for internal use |
procedure raiseFORG0001InvalidConversion(const v: IXQValue; const convTo: string); |
|
procedure raiseXPTY0004TypeError(const v: IXQValue; const convTo: string); |
|
procedure raiseFOTY0013TypeError(const v: IXQValue); |
|
procedure raiseXQEvaluationError(const code, s: string; const data: IXQValue); |
|
Types
TXQValueKind = (...); |
Type of xqvalue (see TXQValue)
Values
-
pvkUndefined:
-
pvkBoolean:
-
pvkInt64:
-
pvkFloat:
-
pvkBigDecimal:
-
pvkString:
-
pvkQName:
-
pvkDateTime:
-
pvkSequence:
-
pvkNode:
-
pvkObject:
-
pvkArray:
-
pvkNull:
-
pvkFunction:
|
TXQTermFlowerOrderEmpty = (...); |
Values
-
xqeoStatic:
-
xqeoEmptyLeast:
-
xqeoEmptyGreatest:
|
TXQDefaultNamespaceKind = (...); |
Values
-
xqdnkUnknown:
-
xqdnkAny:
-
xqdnkElementType:
-
xqdnkType:
-
xqdnkFunction:
|
TXQPropertyDotNotation = (...); |
If it is possible to access object properties with .property xqpdnDisallowDotNotation: do not allow the dot operator anywhere xqpdnAllowUnambiguousDotNotation: allow the dot operator when disabling it would be a syntax error. E.g. cases like ($obj).property , func(..).property , {"a": ..}.property , ... xqpdnAllowFullDotNotation: allow the dot operator everywhere. Even in $obj.property
Values
-
xqpdnDisallowDotNotation:
-
xqpdnAllowUnambiguousDotNotation:
-
xqpdnAllowFullDotNotation:
|
TTreeNodeSerialization = (...); |
Values
-
tnsText:
-
tnsXML:
-
tnsHTML:
|
TXQParsingModel = (...); |
Values
-
xqpmXPath2:
-
xqpmXQuery1:
-
xqpmXPath3:
-
xqpmXQuery3:
|
TXSConstrainingFacetKind = (...); |
Values
-
xsfLength:
-
xsfMinLength:
-
xsfMaxLength:
-
xsfPattern:
-
xsfEnumeration:
-
xsfMaxInclusive:
-
xsfMinInclusive:
-
xsfTotalDigits:
-
xsfFractionDigits:
-
xsfAssertions:
-
xsfExplicitTimezone:
|
TXSConstrainingFacetWhitespace = (...); |
Values
-
xsfwAbsent:
-
xsfwPreserve:
-
xsfwReplace:
-
xsfwCollapse:
|
TXSConstrainingFacetExplicitTimeZone = (...); |
Values
-
xsfetRequired:
-
xsfetProhibited:
-
xsfetOptional:
|
TXSCastingError = (...); |
Values
-
xsceNoError:
-
xsceXPTY0004:
-
xsceFORG0001:
-
xsceFOCA0002:
-
xsceFODT0001:
-
xsceFODT0002:
-
xsceFOAR0002:
|
TXSNumericSubType = (...); |
Values
-
xsstInteger:
-
xsstDecimal:
-
xsstFloat:
-
xsstDouble:
|
TXSStringSubType = (...); |
XML Schema string type, derived from xs:string, xs:anyURI, xs:hexBinary, xs:base64Binary or xs:untypedAtomic
Values
-
xsstString:
-
xsstHexBinary:
-
xsstBase64Binary:
-
xsstUrl:
|
TXQDateTimeTruncation = (...); |
Values
-
xqdttNone:
-
xqdttTime:
-
xqdttDate:
-
xqdttYearMonth:
|
TXSSchemaVersion = (...); |
Values
|
TXQBasicFunction = function (argc: SizeInt; argv: PIXQValue): IXQValue; |
Basic/pure function, taking some TXQValue-arguments and returning a new IXQValue.
It should not modify the values passed in the args in case there are other references, but it may assign one of them to result.
|
TXQComplexFunction = function (const context: TXQEvaluationContext; argc: SizeInt; argv: PIXQValue): IXQValue; |
Function, taking some TXQValue-arguments and returning a new TXQValue which can depend on the current context state
It should not modify the values passed in the args in case there are other references, but it may assign one of them to result.
|
TXQBinaryOp = function (const cxt: TXQEvaluationContext; const a,b: IXQValue): IXQValue; |
Binary operator of TXQValues
It should not modify the values passed in the args in case there are other references, but it may assign one of them to result.
|
TXQContextDependency = (...); |
The dynamic/static context values a query depends on (internal used for optimizations) xqcdFocusItem: context item/node (e.g. .) xqcdFocusPosition: index (e.g. position()) xqcdFocusLast: size (e.g. last()) xqcdContextCollation, xqcdContextTime, xqcdContextVariables, xqcdContextOther: context, obvious
Values
-
xqcdFocusItem:
-
xqcdFocusPosition:
-
xqcdFocusLast:
-
xqcdContextCollation:
-
xqcdContextTime:
-
xqcdContextVariables:
-
xqcdContextOther:
|
TXQOperatorFlags = set of (xqofAssociativeSyntax, xqofCastUntypedToString,
xqofCastUntypedToDouble); |
Information about a xquery binary operator
|
TXQPathMatchingAxis = (...); |
Values
-
qcSameNode:
-
qcDirectParent:
-
qcDirectChildImplicit:
-
qcDirectChild:
-
qcSameOrDescendant:
-
qcDescendant:
-
qcFollowing:
-
qcFollowingSibling:
-
qcAncestor:
-
qcPrecedingSibling:
-
qcPreceding:
-
qcSameOrAncestor:
-
qcDocumentRoot:
-
qcFunctionSpecialCase:
-
qcAttribute:
|
TXQPathMatchingKind = (...); |
Values
-
qmValue:
-
qmElement:
-
qmText:
-
qmComment:
-
qmProcessingInstruction:
-
qmAttribute:
-
qmDocument:
-
qmSchemaFail:
-
qmCheckNamespaceURL:
-
qmCheckNamespacePrefix:
-
qmCheckOnSingleChild:
|
TXQPathNodeConditionIteration = (...); |
Values
-
qcnciNext:
-
qcnciPreceding:
-
qcnciParent:
|
TXQPathNodeConditionOption = (...); |
Values
-
xqpncMatchStartNode:
-
xqpncCheckValue:
-
xqpncCheckNamespace:
-
xqpncCheckOnSingleChild:
|
TXQTerm_VisitAction = (...); |
Values
-
xqtvaContinue:
-
xqtvaAbort:
-
xqtvaNoRecursion:
|
TXQTypeInformationKind = (...); |
Values
-
tikNone:
-
tikAny:
-
tikAtomic:
-
tikFunctionTest:
-
tikElementTest:
-
tikUnion:
|
TXQNamespaceMode = (...); |
Values
-
xqnmNone:
-
xqnmURL:
-
xqnmPrefix:
|
TXQTermDefineFunctionKind = (...); |
Values
-
xqtdfUserDefined:
-
xqtdfNamedReference:
-
xqtdfStaticPartialApplication:
-
xqtdfDynamicPartialApplication:
|
TXQTermNodeMatcherDirect = (...); |
Values
|
TXQTermNamedFunctionKind = (...); |
Values
-
xqfkBasic:
-
xqfkComplex:
-
xqfkNativeInterpreted:
-
xqfkUnknown:
-
xqfkTypeConstructor:
|
TXQTermFlowerSubClauseKind = (...); |
Values
-
xqtfcFor:
-
xqtfcLet:
-
xqtfcWindow:
-
xqtfcForPattern:
-
xqtfcLetPattern:
-
xqtfcWhere:
-
xqtfcOrder:
-
xqtfcCount:
-
xqtfcGroup:
|
TXQTermFlowerWindowFlags = set of (xqtfwSliding , xqtfwEndOnlyWhen); |
|
TXQTermFlowerWindowVariableCallback = procedure (data: pointer; v: TXQTermVariable); |
|
TXQExceptionEvent = procedure (exception: EXQException) of object; |
|
TXQEvaluateVariableEvent = function (sender: TObject; const variable: string; var value: IXQValue): boolean of object; |
Event callback that is called to receive the value of the variable variable
. Should return true, if the value was changed. (returning false will cause an unknown variable exceptiono)
|
TXQDeclareExternalVariableEvent = procedure(sender: TObject; const context: TXQStaticContext; const namespaceUrl, variable: string; var value: IXQValue) of object; |
Event callback that is called to set the value of a XQuery variable declared as "declare variable ... external"
.
The return value can be created with one of the xqvalue(..) functions.
|
TXQDeclareExternalFunctionEvent = procedure(sender: TObject; const context: TXQStaticContext; const namespaceURL, functionName: string; var result: TXQValueFunction) of object; |
Event callback that is called to set a function value of a XQuery function declared as "declare function ... external"
.
The function in result has already been initialized with the parameters and result type, only the term in result.body has to be set. You can either create an syntax tree for the function with the respective TXQTerm classes or derive a class from TXQTerm and override the evaluate function to calculate it natively.
|
TXQImportModuleEvent = procedure (sender: TObject; const namespace: string; const at: array of string) of object; |
|
TXQTraceEvent = procedure (sender: TXQueryEngine; value, info: IXQValue) of object; |
Event called by the fn:trace(value,info) function.
|
TXQParseDocEvent = procedure (sender: TXQueryEngine; data, url, contenttype: string; var node: TTreeNode) of object; |
Event called by the fn:doc to parse a downloaded document.
|
TXQFormatIntegerModifier = (...); |
Modifier for integer formatting, as described in fn:format-integer. The absence of xqfimOrdinal means cardinal , the absence of traditional means alphabetic. (traditional is a traditional way of writing integers with letters, e.g. roman numbers)
Values
-
xqfimOrdinal:
-
xqfimTraditional:
|
TXQFormatIntegerEvent = procedure (sender: TObject; integerNumber: BigDecimal; primaryFormat, modifierVariant, language: string; modifiers: TXQFormatIntegerModifiers; var formatted: string) of object; |
|
TXQDecimalFormatProperty = (...); |
Values
-
xqdfpDecimalSeparator:
-
xqdfpGroupingSeparator:
-
xqdfpMinusSign:
-
xqdfpPercent:
-
xqdfpPerMille:
-
xqdfpZeroDigit:
-
xqdfpDigit:
-
xqdfpPatternSeparator:
-
xqdfpExponentSeparator:
|
Constants
MY_NAMESPACE_PREFIX_URL = 'http://www.benibela.de/2012/pxp/'; |
|
XMLNamespaceURL_XPathFunctions = 'http://www.w3.org/2005/xpath-functions'; |
|
XMLNamespaceURL_XPathFunctionsMath = 'http://www.w3.org/2005/xpath-functions/math'; |
|
XMLNamespaceURL_XMLSchema = 'http://www.w3.org/2001/XMLSchema'; |
|
XMLNamespaceURL_XMLSchemaInstance = 'http://www.w3.org/2001/XMLSchema-instance'; |
|
XMLNamespaceURL_XQueryLocalFunctions = 'http://www.w3.org/2005/xquery-local-functions'; |
|
XMLNamespaceURL_XQTErrors = 'http://www.w3.org/2005/xqt-errors'; |
|
XMLNamespaceURL_MyExtensionsNew = 'http://pxp.benibela.de'; |
|
XMLNamespaceURL_XQuery = 'http://www.w3.org/2012/xquery'; |
|
MicroSecsPerSec = int64(1000000); |
|
MATCH_ALL_NODES = [qmText,qmComment,qmElement,qmProcessingInstruction,qmAttribute,qmDocument]; |
|
Variables
XQGlobalTrimNodes: boolean = true; |
If XQGlobalTrimNodes is true, the result of every node->string conversion is trimmed. This trimming occurs after and not during the conversion. E.g. If it is true, text() and deep-text() for <a> a </a> return 'a', and deep-text() for <x><a> a </a><a> b </a></x> returns 'a b'. (This variable should actually be a property of TXQueryEngine, but that is not possible in the current design, since the values convert themself, and don't know their corresponding parser)
|
XQGlobalUseIDfromDTD: boolean = false; |
If XQGlobalUseIDfromDTD is false, the fn:*id* functions will thus assume every attribute with name id is an ID attribute If XQGlobalUseIDfromDTD is true, only real ID attributes are used. However, simplehtmltreeparser cannot handle DTDs, so it cannot detect ID attributes. So if this is true, only the wrapped fcl-xml parser from simplehtmltreeparserfpdom can be used
|
GlobalStaticNamespaces: TNamespaceList; |
List of namespaces which are known in all XPath/XQuery expressions, even if they are not declared there
|
AllowJSONDefaultInternal: boolean = false; |
Default setting for JSON (internally used).
|
XQDefaultDecimalFormat: TXQDecimalFormatPropertyData = (
chars: (ord('.'), ord(','), ord('-'), ord('%'), $2030, ord('0'), ord('#'), ord(';'), ord('e') );
infinity: 'Infinity';
nan: 'NaN'); |
|
Author
Generated by PasDoc 0.14.0.
|