Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Saxon.XPathQuery
Runs a XPath query.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Saxon | 15.0 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
xml | The XML to work on. | ||
query | The query to run. | ||
VariableList | List of parameters to become variables. | Optional |
Result
Returns XML or error.
Description
Runs a XPath query.You can set the language version with Saxon.SetLanguageVersion function.
Set the current working directory with Saxon.SetCWD function, so the function can find relative files.
XPath 3.1 Basic
Provides all XPath 3.1 features which do not require schema-awareness or higher-order functions. This includes an implementation of maps and arrays, and support for JSON, as well as language constructs retained from earlier XPath versions.
XPath 3.1 Higher-Order
Provides higher-order functions: specifically, the ability to use functions as values, including dynamic function calls, inline functions, partial function application, and a library of built-in higher-order functions.
XPath 3.1 Schema Aware with EE-V license
Provides schema-awareness: specifically, any use of source documents with type annotations, and any use of XPath expressions that contain the names of schema components such as element declarations and types, other than the built-in types.
Examples
Run query:
MBS("Saxon.XPathQuery";
"<out><person>text1</person><person>text2</person><person>text3</person></out>";
"//person[1]")
Example result: <person>text1</person>
Run with two variables:
Set Variable [ $r ; Value: MBS( "Saxon.Clear") ]
# put in the value for the variable
Set Variable [ $r ; Value: MBS( "Saxon.SetParameter"; "param"; "1"; "integer") ]
Set Variable [ $r ; Value: MBS( "Saxon.SetParameter"; "other"; "2.4"; "json") ]
# now run a query and pass list of variables
Set Variable [ $query ; Value: "$param+$other" ]
Set Variable [ $VariableList ; Value: "param¶other" ]
Set Variable [ $r ; Value: MBS( "Saxon.XPathQuery"; "<test/>"; $Query; $VariableList ) ]
Set Field [ Saxon XSLT::Result ; $r ]
See also
Example Databases
Blog Entries
This function checks for a license.
Created 23th December 2024, last changed 9th January 2025