Bosak.XPath.Api 0.12.0-beta

This is a prerelease version of Bosak.XPath.Api.
dotnet add package Bosak.XPath.Api --version 0.12.0-beta
                    
NuGet\Install-Package Bosak.XPath.Api -Version 0.12.0-beta
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bosak.XPath.Api" Version="0.12.0-beta" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bosak.XPath.Api" Version="0.12.0-beta" />
                    
Directory.Packages.props
<PackageReference Include="Bosak.XPath.Api" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bosak.XPath.Api --version 0.12.0-beta
                    
#r "nuget: Bosak.XPath.Api, 0.12.0-beta"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bosak.XPath.Api@0.12.0-beta
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bosak.XPath.Api&version=0.12.0-beta&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Bosak.XPath.Api&version=0.12.0-beta&prerelease
                    
Install as a Cake Tool

<div align="center"> <img src="assets/logos/fytala-logo-color-dark.svg" width="100" alt="Fytala Bosak XPath engine"> <br><br> <h1>Bosak XPath</h1> <p>A high-performance, XDM-first XPath 3.1, XSLT 3.0 and XQuery 3.1 engine for .NET</p> </div>

<div align="center">

.NET 10 License Status NuGet CI XSLT 3.0 conformance

</div>


About FYTALA

FYTALA — Feeling Young, Thriving, Active, Learning Always — is a personal initiative founded after retirement, driven by the belief that curiosity, enthusiasm, and learning have no age limit.

It is about staying engaged, exploring new ideas, and sharing the excitement of technology and innovation with others. A special ambition of FYTALA is to spark that enthusiasm in young people and encourage them to discover how fascinating technology can be—not just by talking about technology, but by making it visible, tangible, surprising, and fun.

My dream captures that ambition perfectly: to walk into a classroom one day, side by side with a humanoid robot, and make my enthusiasm for technology and innovation contagious.

If that experience inspires even a few young minds to start asking questions, experimenting, building, programming, or imagining what might be possible, FYTALA has achieved something worthwhile.

Technology, after all, is not just about machines, electronics, or software. It is about curiosity, creativity, and turning ideas into reality. FYTALA therefore takes a deliberately broad perspective, embracing software, electronics, engineering, science, artificial intelligence, robotics, and whatever comes next.

Experimenting matters.

Making mistakes matters.

Understanding why something works matters even more.

Every project is an opportunity to learn something new and, hopefully, to help someone else learn as well.

The cable-stayed bridge in the FYTALA logo represents that philosophy. A bridge connects places, but it can also connect people, ideas, generations, and fields of knowledge. Its strength comes from many individual elements working together—much like technology itself.

FYTALA wants to help build those bridges: between experience and youthful curiosity, theory and practice, and imagination and real-world creation. It encourages looking beyond the obvious, asking questions, taking things apart, and building them again in new ways.

Above all, FYTALA is about keeping the desire to discover alive—and passing that desire on to the next generation.

Because we never have to stop being curious.

We never have to stop creating.

And we are never too old—or too young—to learn something new.


Overview

Bosak is a ground-up .NET implementation of XPath 3.1 (with forward-compatibility for 4.0), with full XSLT 3.0 and XQuery 3.1 processors built on the same expression engine.

The project is named for Jon Bosak, who chaired the W3C working groups that created XSLT and XPath and donated the XML logo to the community — the standards this engine implements.

Unlike System.Xml.XPath, Bosak is built on the W3C XQuery Data Model (XDM) from day one. Expressions are compiled once to an intermediate representation (IR) and executed many times on a lightweight, register-based virtual machine. XSLT and XQuery reuse the same XPath engine for all expression evaluation.

Key Features

  • XDM-First Architecture — All inputs are adapted to IXdmNode; no proprietary DOM lock-in
  • Compile Once, Execute Many — Parse → Optimize → Lower to IR → VM execution
  • Zero-Allocation Sequences — Lazy struct enumerators avoid IEnumerable<T> boxing on hot paths
  • Pluggable Backends — Works with XDocument, XmlDocument, streaming readers, or custom IXdmNode providers
  • XPath 3.1 Complete — Maps, arrays, higher-order functions, arrow expressions (=>), string concat (||), FLWOR, JSON functions
  • XSD Regex with Pinned Unicode 9.0 — Full \p{X}/\P{X} category and \p{IsBlock} support, class subtraction, astral-safe matching
  • XSLT 3.0 Transform Engine — Template matching, sequence constructors, xsl:copy/xsl:copy-of, xsl:for-each-group, xsl:analyze-string, xsl:where-populated, xsl:on-empty, xsl:iterate/xsl:break, fn:transform()
  • Burst-Mode Streaming Input — XmlStreamingProvider + XsltExecutable.TransformStreaming/TransformStreamingToString process multi-GB record documents in bounded memory (verified at 500k records); forward-only with loud errors instead of silent data loss; pre-root comment/PI parity with the in-memory provider; push-style streaming accumulators (xsl:accumulator works over the stream)
  • XQuery 3.1 (Phase 4) — full core FLWOR, direct and computed constructors, switch/typeswitch, validate (strict/lax/type QName), output declarations and serialization, user-defined functions and variables, library modules (import module with %public/%private visibility), schema-aware user-defined simple types, QName/NOTATION preservation and ID/IDREF detection, higher-order function item instance-of over element kind tests, empty document-node() matching, constructed-element xs:anyType annotations, QName accessor singleton-sequence XPTY0004, function return-type atomization for user-defined schema types, keywords as unprefixed function names, instance-of type-hierarchy semantics for user-defined schema types; schema-aware fn:json-to-xml with validate:=true() against the W3C schema-for-JSON; QT3 wired (31,142/0/679 strict — 100% of runnable)

Quick Start

dotnet add package Bosak.XPath.Api --prerelease   # XPath entry point
# or: dotnet add package Bosak.Xslt --prerelease  # XSLT 3.0 transforms
# or: dotnet add package Bosak.XQuery --prerelease # XQuery 3.1 queries
using Bosak.XPath.Api;
using Bosak.XPath.Core.Xdm;

// Compile once
var expr = XPath31Expression.Compile("$price * (1 + $taxRate)");

// Execute many times with different inputs
var ctx = new EvaluationContext()
    .WithVariable("price", XdmValue.FromDecimal(100.00m))
    .WithVariable("taxRate", XdmValue.FromDecimal(0.21m));

var result = expr.Evaluate(ctx);
Console.WriteLine(result.DecimalValue); // 121.00

Conditional Expressions

var expr = XPath31Expression.Compile(
    "if ($score ge 90) then 'A' else if ($score ge 80) then 'B' else 'C'");

Sequence & Range

var expr = XPath31Expression.Compile("1 to 5");
// Returns: [1, 2, 3, 4, 5]

XQuery 3.1

using Bosak.XQuery.Api;
using Bosak.XPath.Core.Xdm;

var query = new XQueryCompiler().Compile("for $i in 1 to 3 return $i * $i");
var result = query.Evaluate(new XQueryContext());

foreach (var item in XdmSequence.FromSource(result.SequenceValue!))
    Console.WriteLine(item.IntegerValue);
// => 1 4 9

Architecture

flowchart TB
    subgraph Input["📄 Input"]
        XPATH["XPath 3.1 Expression"]
    end

    subgraph Compiler["🔧 Compiler Pipeline"]
        LEXER["Lexer<br/><small>ReadOnlySpan&lt;char&gt;</small>"]
        PARSER["Parser<br/><small>Recursive Descent AST</small>"]
        OPTIMIZER["Optimizer<br/><small>Constant Fold / DCE</small>"]
        LOWERER["IR Lowerer<br/><small>Register-Based IR</small>"]
    end

    subgraph Runtime["⚡ Runtime"]
        VM["Register VM<br/><small>VmEngine.Execute</small>"]
        FUNCS["Function Library<br/><small>fn, math, map, array, xs</small>"]
    end

    subgraph Output["📤 Output"]
        XDM["XdmValue"]
    end

    XPATH --> LEXER
    LEXER --> PARSER
    PARSER --> OPTIMIZER
    OPTIMIZER --> LOWERER
    LOWERER --> VM
    VM --> XDM
    FUNCS --> VM

    classDef current fill:#F0FFF0,stroke:#518D8F,color:#2F4F4F,stroke-width:2px
    classDef external fill:#FFFFFF,stroke:#293F5F,color:#2F4F4F

    class LEXER,PARSER,OPTIMIZER,LOWERER,VM,FUNCS current
    class XPATH,XDM external

Layer Stack

Layer Project Responsibility
Public API Bosak.XPath.Api XPath31Expression, CompileOptions, EvaluationContext
Standard Library Bosak.XPath.Standard fn:*, math:*, map:*, array:*, xs:* constructors
Runtime / VM Bosak.XPath.Runtime VmEngine, function dispatch, sequence operators
Compiler / IR Bosak.XPath.Compiler XPathOptimizer, IrLowerer, bytecode emitter
Parser Bosak.XPath.Parser XPathLexer, XPathParser, AST nodes
XDM Core Bosak.XPath.Core XdmValue, IXdmNode, XdmSequence, axis kinds
Node Providers Bosak.XPath.Providers XDocument, XmlDocument, burst-mode streaming (XmlStreamingProvider)
XSLT Bosak.Xslt XsltCompiler, TransformEngine, fn:transform()
XQuery Bosak.XQuery XQueryCompiler, XQueryExecutable, XQueryParser, XQueryStaticContext; full core FLWOR + direct and computed constructors + switch/typeswitch + output declarations and serialization + user-defined functions/variables + library modules + schema-aware user-defined simple types; QT3 wired (31,142/0/679 strict — 100% of runnable)
Language Server Bosak.LanguageServer LSP server for XPath / XSLT / XQuery — diagnostics, completions, hover, go-to-definition, document outline, semantic tokens, code actions, code lens
VS Code Extension vscode-bosak/ TypeScript client for the language server

Performance Strategy

Technique Application
ReadOnlySpan<char> Lexer, string comparisons, name tests
Struct enumerators XdmSequence, axis iteration
ArrayPool<T> Temporary buffers during sorting / materialization
Lazy evaluation Sequences, predicates, path steps
Register VM Expression execution (better cache locality than tree walking)
IL JIT (future) Hot expression compilation to DynamicMethod

Roadmap

Phase Deliverable Status
1 XPath 3.1 Core — compiler + VM + standard functions ✅ Complete
2 XSLT 2.0/3.0 — template matching, sequence constructors, fn:transform() ✅ Complete — full option surface + QT3 Tier-2m (117/124 passed, 7 skipped)
3 XQuery 3.1 — prolog parser, static context, prolog-less queries, full core FLWOR 🚧 Phase 4 (constructors, modules, serialization, HOF, fn:load-xquery-module, schema-aware user-defined simple types, validate, QName/NOTATION/ID support, QName accessor singleton-sequence XPTY0004, function return-type atomization for user-defined schema types, schema-aware fn:json-to-xml); QT3 wired (31,142/0/679 strict — 100% of runnable)
4 Streaming — XmlReader-backed IXdmNode ✅ Phases A+B+C+D — burst-mode streaming input (XmlStreamingProvider, TransformStreaming, TransformStreamingToString) + push-style streaming accumulators + streamable="yes" (§19 analyzer + runtime posture); provider batch: per-node wrapper cache, pre-root comment/PI surfacing, fn:copy-of deep-copy guard
5 Database backends — XML database adapters 📋 Planned

Support

The open-source library is community-supported and free forever (Apache-2.0):

  • Questions & usage help → GitHub Discussions (Q&A category)
  • Bugs & feature requests → GitHub Issues
  • Engine correctness work — conformance fixes and correctness improvements are always done in the open; they are never paywalled

For guaranteed response times, direct engineering access, priority triage, or custom development, Fytala offers commercial support contracts. A future "Bosak Pro" add-on is planned for advanced schema-awareness scenarios; the conformant engine core stays Apache-2.0 regardless.


VS Code Extension

A Language Server Protocol (LSP) implementation and VS Code extension provide IDE features for XPath, XSLT, and XQuery development — syntax highlighting, semantic tokens, diagnostics, completion, hover, go-to-definition, document outline, code actions (quick fixes), code lens for .xpath/.xq/.xqy/.xquery results, XSLT Run XSLT transformation and Run initial template lenses, workspace/executeCommand evaluation, and evaluate/run commands.

Quick Install

# 1. Build the language server
dotnet build src/Bosak.LanguageServer/Bosak.LanguageServer.csproj

# 2. Build the extension
cd vscode-bosak
npm install
npm run compile

# 3. Open in VS Code and press F5 to launch the Extension Development Host

See vscode-bosak/README.md for full installation options (VSIX, custom server path, troubleshooting).


Building

dotnet build Bosak.sln
dotnet test Bosak.sln

Target framework: .NET 10.

All 2,111 unit tests pass (0 failures).


Conformance Testing

Bosak includes a W3C QT3 test suite harness for measuring XPath 3.1 standards compliance.

Running the Harness

# Build the conformance runner
dotnet build tests/Bosak.XPath.Conformance/Bosak.XPath.Conformance.csproj

# Run against the full QT3 suite (~32,000 tests across 428 test sets)
dotnet run --project tests/Bosak.XPath.Conformance/Bosak.XPath.Conformance.csproj

The harness:

  1. Discovers all test sets from tests/qt3tests/catalog.xml
  2. Filters out unsupported features (schema-aware, XSLT streaming-only, serialization, static typing)
  3. Routes XQuery-syntax tests through the Bosak.XQuery pipeline; evaluates the rest via the public XPath31Expression.Compile(expr).Evaluate(ctx) API
  4. Executes each test with environment-defined namespaces, variables, and context documents wired in
  5. Compares results against QT3 assertions (assert-eq, assert-true, assert-xml, etc.) with strict error-code matching

Current Results

Metric Value
XPath/XQuery (QT3) 428 test sets, ~32,000 tests
Pass Rate (XPath+XQuery) 31,142 passed / 0 failed / 679 skipped (97.87%) with strict error-code matching (2026-09-09) — 100% of runnable tests pass
XSLT 3.0 224 test sets, 14,600 tests
Pass Rate (XSLT) 10,220 passed / 55 failed / 4,325 skipped (99.4%, 2026-09-21, streaming Phases A–D live + si-fork residual batch + provider batch + use-when batch + su-filter/su-unclassified analyzer batch + si-iterate XTSE3120 batch + si-message assert-message batch + sx-MapExpr map-constructor batch + sx-treat/sx-instance-of braced-EQName batch + xml-to-json package-namespace batch; re-run 2026-09-22 with REQ-097 schema-aware seam — unchanged) — failures triaged: schema-gated XTSE1650 (~24), assorted documented singles; see REQ-086/REQ-087/REQ-088/REQ-089/REQ-090/REQ-091/REQ-092/REQ-093/REQ-094/REQ-095 decision logs
unicode-90 set 1,365 passed / 0 failed / 95 skipped (skips are upstream test/data defects)
Unsupported Features Schema awareness (in progress), XQuery-only dependencies

Strict error matching — Both conformance harnesses now require the declared <error code="..."> to match the raised exception; previously any error satisfied an error expectation. The XSLT strict count (2026-09-01) exposed 147 tests that passed with a wrong error code (lenient figure 7,627/103/6,870). The QT3 strict tightening (2026-09-07) exposed 1,200 wrong-code passes; the triage fixed ~970 of them — cast-matrix error codes, static XPST0003/XPST0081/XPST0008 checks at parse/compile time, XQDY0054 dynamic detection, FOER0000 structural matching — leaving 233 triaged failures (documented engine gaps: schema list-type casts, extreme date/time ranges, JSON parse error-code granularity). No genuinely passing test was lost in either sweep.

Known Limitations

Assertion Status Impact
assert-eq ✅ Implemented Core value comparison
assert-count ✅ Implemented Sequence cardinality
assert-deep-eq ✅ Implemented Recursive XDM comparison
assert-xml ⚠️ Partial ~1,840 tests skipped
assert-permutation ❌ Not implemented ~92 tests skipped
Schema-aware ⚠️ Opt-in (REQ-097) ~5,000+ tests skipped — XSLT schema-aware compilation compiles xsl:import-schema and supports user-defined simple types via SchemaAware / SchemaResolver / SchemaSet; complex-type typed construction and runtime validation remain planned (Bosak.Schema track)

Adding New Tests

The harness is intentionally thin — it validates the public API surface end-to-end rather than calling internal layers directly. This ensures that parser, compiler, VM, and standard-library fixes are all exercised together.


<div align="center" style="background:#2F4F4F; color:#F0FFF0; padding:1rem; border-radius:12px; margin-top:2rem;"> <p style="margin:0; font-family:Poppins,Segoe UI,sans-serif;"> <strong>© Fytala</strong> — Bosak XPath Engine </p> </div>

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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Bosak.XPath.Api:

Package Downloads
Bosak.XQuery

Bosak: pure-managed XQuery 3.1 processor for .NET — FLWOR, modules, constructors and the full XQuery function library. Part of the Bosak XPath 3.1 / XSLT 3.0 / XQuery 3.1 stack.

Bosak.Xslt

Bosak: pure-managed XSLT 3.0 processor for .NET — the open-source XSLT 3.0 engine with 99.9% W3C conformance. Packages, modes, streaming-ready processing, fn:transform(). Part of the Bosak XPath 3.1 / XSLT 3.0 / XQuery 3.1 stack.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.12.0-beta 65 9/23/2026
0.11.0-beta 54 9/22/2026
0.10.2-beta 59 9/21/2026
0.10.1-beta 60 9/18/2026
0.10.0-beta 84 9/9/2026
0.9.1-preview 77 9/6/2026
0.9.0-preview 97 9/5/2026