#XSLT

XSLT (Extensible Stylesheet Language Transformations) is a declarative language for transforming XML documents. If you've written Razor views, Handlebars templates, or even CSS selectors, XSLT takes that idea further — pattern matching on XML trees to produce any output format.

XSLT is how you turn XML data into HTML pages, other XML formats, JSON, CSV, or plain text. It's the transformation layer that makes XML practical.

#Getting Started

  • Your First Transform — A hands-on introduction. Transform XML to HTML, step by step.

  • Template Matching — The core paradigm shift: declarative rules instead of imperative code.

  • Output Methods — Producing HTML, XML, JSON, CSV, and text from the same source data.

  • Extensibility — Custom functions, packages, extension instructions, and .NET integration.

#Instructions Reference

The complete set of XSLT 3.0/4.0 instructions, organized by purpose:

#Streaming

PhoenixmlDb supports XSLT 3.0 streaming for processing documents that are too large to fit in memory. Streaming processes the input as a forward-only event stream, never building the full tree.

Key capabilities:

  • Primary source streaming — Declare xsl:mode streamable="yes" to stream the principal input document via XmlReader

  • External document streaming — Use xsl:source-document streamable="yes" to stream documents loaded during transformation

  • Accumulators — Maintain running state (counts, totals, max values) as nodes flow past

  • Static streamability checking — The compiler analyzes your stylesheet and reports streamability violations at compile time

  • system-property('xsl:supports-streaming') returns "yes"

  • Limitations: last() is not available in streaming mode; xsl:fork branches execute sequentially (not in parallel)

#The Mental Model

If you're a C# developer, think of XSLT like this:

C# Concept

XSLT Equivalent

A method that takes input and returns output

A template rule that matches a node and produces output

switch on type

Template matching with match patterns

foreach over a collection

xsl:for-each or xsl:apply-templates

String interpolation

Attribute value templates: href="{@url}"

Method overloading

Template priority and import precedence

The key difference: in C# you write imperative code that says how to process data. In XSLT you write declarative rules that say what to produce for each pattern. The XSLT engine handles the traversal.