xquery4 2.4.1

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global xquery4 --version 2.4.1
                    
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 2.4.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=xquery4&version=2.4.1
                    
nuke :add-package xquery4 --version 2.4.1
                    

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.

A patch for a regression in 2.4.0 that **broke XSpec compilation** (phoenixmldb-xslt#191, reported
by Martin Honnen two hours after 2.4.0 shipped).

### Fixed

**A string subtype had no effective boolean value.** `if (xs:NCName('a'))` raised `FORG0006`
instead of returning true. The spec says a value of type `xs:string` or anything derived from it is
true when non-empty. This hole predates 2.4.0, but it was unreachable in practice until 2.4.0
correctly made `fn:prefix-from-QName` return `xs:NCName` (and `fn:default-language` return
`xs:language`). XSpec's compiler tests a prefix in an `if`, so every XSpec suite stopped compiling.

The same sweep found three other places that switched on runtime type with no string-subtype case:

- **Map keys.** An `xs:NCName` key and an equal `xs:string` were different keys, so lookups missed
 and merges kept duplicates.
- **`fn:translate`** rejected a string subtype with `XPTY0004`.
- **`fn:collation-key`** (both arities) rejected it too.

49 operations on subtype values were checked in all; the rest were already correct.

### `xquery` CLI (ships on `cli-v2.4.1`)

Runs on PhoenixmlDb.Xslt 2.4.1, so an `xsl:if` or `xsl:when` test on a string subtype, a float
or a typed integer in a stylesheet called through `fn:transform` no longer raises `FORG0006`.

### Conformance

Per-case QT3 diff against 2.4.0: **no changes**. Neither suite has a case for these shapes, which
is why the regression shipped. XSpec compilation now gates every release.