xquery4 1.6.8

dotnet tool install --global xquery4 --version 1.6.8
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local xquery4 --version 1.6.8
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=xquery4&version=1.6.8
                    
nuke :add-package xquery4 --version 1.6.8
                    

xquery

Command-line XQuery 3.1/4.0 processor for .NET. Query XML documents from the terminal using the PhoenixmlDb XQuery engine.

Installation

dotnet tool install -g xquery4

Usage

# Query an XML file
xquery '//book/title' library.xml

# Count elements
xquery 'count(//item)' catalog.xml

# Read from a query file
xquery -f transform.xq input.xml

# Query a directory of XML files
xquery 'collection()//product[price > 50]' ./data/

# JSON output
xquery -o json 'map { "count": count(//item) }' data.xml

# Read from stdin
cat data.xml | xquery '//item/@name'

# Show execution plan
xquery --plan 'for $x in 1 to 10 return $x * $x'

# Show timing breakdown
xquery --timing '//item' large-catalog.xml

Features

  • XQuery 3.1/4.0 — FLWOR, maps/arrays, higher-order functions, string constructors
  • Multiple output methods — adaptive, XML, text, JSON
  • Context item — input XML is available as . (standard XQuery)
  • Multiple sources — files, directories, URLs, stdin
  • Full prolog support — namespaces, variable/function declarations, serialization options
  • Execution plans — inspect how queries are compiled and optimized
  • Timing — built-in performance profiling

Documentation

Full documentation at phoenixml.dev

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.6.8 0 8/26/2026
1.6.7 55 8/24/2026
1.6.6 63 8/23/2026
1.6.5 60 8/21/2026
1.6.2 78 8/16/2026
1.6.1 72 7/31/2026
1.6.0 82 7/27/2026
1.5.5 90 7/12/2026
1.5.4 79 7/9/2026
1.5.3 81 7/8/2026
1.5.2 80 7/7/2026
1.5.1 94 6/30/2026
1.5.0 80 6/28/2026
1.4.7 87 6/25/2026
1.4.6 96 6/17/2026
1.4.5 91 6/17/2026
1.4.4 86 6/14/2026
1.4.3 88 6/10/2026
1.4.2 88 6/6/2026
1.4.1 96 6/4/2026
Loading failed

Eight XPath 4.0 gaps, found by running a real 4.0 library rather than a conformance suite,
plus two diagnostics that were describing the runtime's internals to people writing XQuery.

### Eight XPath 4.0 gaps, from Dimitre Novatchev's Generator Function Library

The library (Balisage 2026) is real XPath 4.0 code, verified by its author against BaseX and
Saxon. It found ten gaps in about two hours — none of which 31,470 QT3 cases had reached.
Eight are fixed here and the library now runs, including lazy infinite generators:
`take(10000000) => value()` returns `2` without materialising ten million items.

- **`declare record NAME(...)`** — named record types and the constructor function they
 imply. Emitted as an ordinary function declaration whose body is a map constructor, so it
 inherits parameter binding, arity checking and keyword arguments, which is how the library
 calls it: `f:generator(initialized := true(), ...)`.
- **Imported record types** — approximated: the parser cannot see an imported module, so a
 type named with an imported prefix is assumed to be one it declares.
- **`fn` as a TYPE keyword** — §4.6.6 makes `fn` and `function` synonyms generally. 1.6.7
 fixed inline expressions, which is the half Martin Honnen's report showed; types were left.
- **Named parameters in function types** — `fn($this as T) as U`, how record fields declare
 callbacks.
- **`=?>`, the mapping arrow** — record method dispatch: `E =?> name(args)` is
 `E?name(E, args)`, with `E` evaluated once.
- **`array:empty($a)`** — the arity-1 predicate. A zero-arity `array:empty()` constructor
 already existed under the same name, so "Unknown function: empty#1" was exactly right.
- **`fn:while-do`** — bounded at 10^6 iterations: it drives generators, so a predicate that
 never goes false should raise rather than hang.
- **Digit separators** — `1_000_000`, and in the fraction and exponent too.

### Diagnostics no longer name CLR types

`fn:type(xs:byte(1))` returned the string **`"XsTypedInteger"`** with kind `"item"` — a
shipped XPath 4.0 function handing a C# class name to someone who wrote XQuery. Tagged
subtypes matched no arm of its switch and fell through to `GetType().Name`.

The same cause reached type errors. Declaring `$n as xs:nonNegativeInteger` and passing `2`
reported *"does not match parameterized type Integer"* — wrong three times over: not
parameterized, not `xs:integer`, and "Integer" erases exactly the derived/base distinction
that caused the mismatch. Companion sites printed "but got Int64".

`fn:type` and the engine's diagnostics now share one renderer, so they cannot drift.

### `XQST0059` said "cannot locate" for a schema it had located

`XsdSchemaProvider` caught the per-hint `XmlSchemaException`, discarded it, and reported
"Cannot locate schema for namespace X" — sending the reader after a missing file when the
file was found and failed to COMPILE. It now reports each hint tried and why.

   XQuery.Tests 1497 passed, 0 failed (1466 at 1.6.7)