PhoenixmlDb.XQuery
XQueryFacade
A simple string-in / string-out API for XQuery evaluation.
#XQueryFacade
Namespace: PhoenixmlDb.XQuery
A simple string-in / string-out API for XQuery evaluation.
is the easiest way to evaluate XQuery expressions against XML input. It handles document parsing, engine setup, execution, and result serialization internally, providing a clean "pit of success" experience. The user's XQuery is passed through unmodified β prolog declarations (namespaces, options, variable declarations) work exactly as in any conformant XQuery processor. When input XML is provided, it is available as: The context item (.) β the standard XQuery mechanism $input β declare as declare variable $input external; in the prolog doc('urn:xqueryfacade:input') β explicit URI access Each method creates a fresh and per call, making the facade safe for concurrent use. For high-throughput scenarios where you want to reuse a store across multiple queries, use directly with a shared .
#Properties
| Name | Description |
|---|---|
ResourcePolicy
|
Optional resource security policy. When set, controls which URIs the query can access via doc(), collection(), unparsed-text(), etc. See for a secure server configuration. |
#Methods
#EvaluateAllAsync(String,String,Uri,Uri,Threading.CancellationToken)
Evaluates an XQuery expression and returns each result item as a separate string.
Parameters:
-
xqueryβ The XQuery expression to evaluate. May include a full prolog. -
inputXmlβ Optional XML input. When provided, the parsed document is set as the XQuery context item (available as .), bound as the external variable $input, and accessible via doc('urn:xqueryfacade:input'). The query is passed through unmodified. -
baseUriβ Optional base URI for the input document, enabling relative URI resolution. -
queryBaseUriβ Optional base URI for the XQuery source, for module resolution and fn:static-base-uri(). -
cancellationTokenβ Token to cancel the evaluation.
Returns: A list of serialized result strings, one per result item.
#EvaluateAsync(String,String,Uri,Uri,Threading.CancellationToken)
Evaluates an XQuery expression and returns all results concatenated as a single string.
Parameters:
-
xqueryβ The XQuery expression to evaluate. May include a full prolog. -
inputXmlβ Optional XML input. When provided, the parsed document is set as the XQuery context item (available as .), bound as the external variable $input, and accessible via doc('urn:xqueryfacade:input'). The query is passed through unmodified. -
baseUriβ Optional base URI for the input document. Used as the document-uri and base-uri for the input XML, enabling resolve-uri() and doc() to resolve relative references. Pass the file URI when loading XML from disk (e.g., new Uri(Path.GetFullPath("data.xml"))). Also used as the query base URI if is not set. -
queryBaseUriβ Optional base URI for the XQuery source. Used for fn:static-base-uri() and for resolving relative at location hints in import module declarations. When the query is loaded from a file, pass its URI (e.g., new Uri(Path.GetFullPath("query.xq"))). -
cancellationTokenβ Token to cancel the evaluation.
Returns: All result items serialized and concatenated. Returns an empty string if the result is the empty sequence.
#EvaluateScalarAsync(String,String,Uri,Uri,Threading.CancellationToken)
Evaluates an XQuery expression and returns the first result as a string, or null if empty.
Parameters:
-
xqueryβ The XQuery expression to evaluate. May include a full prolog. -
inputXmlβ Optional XML input. When provided, the parsed document is set as the XQuery context item (available as .), bound as the external variable $input, and accessible via doc('urn:xqueryfacade:input'). The query is passed through unmodified. -
baseUriβ Optional base URI for the input document, enabling relative URI resolution. -
queryBaseUriβ Optional base URI for the XQuery source, for module resolution and fn:static-base-uri(). -
cancellationTokenβ Token to cancel the evaluation.
Returns: The first result item serialized as a string, or null if the result is the empty sequence.