# XSLT

> Transform and query XML documents from SQL with XSLT, XQuery and XPath

This page includes setup, release pins, credentials, hosting and verification evidence. [JSON alternative](https://query.farm/products/orchard/api/v1/connectors/xslt.json) contains the same setup facts for structured readers; choose one format.

## Runtime and release

Use DuckDB or Haybarn **2.0.1** with **VGI protocol 3.4**.
Catalog alias: `xslt`. Release: [v0.5.0](https://github.com/Query-farm/vgi-xslt/releases/tag/v0.5.0). Metadata generated: 2026-12-01T18:22:16+00:00.

## Choose where it runs

- On your machine: use an installation method below. No Query Farm account is required for local execution.
- Self-host: follow [the connector deployment instructions](https://github.com/Query-farm/vgi-xslt) and [connection guide](https://query.farm/vgi/connect-to-a-worker/). Use your real endpoint and its authentication settings.
- Query Farm hosted: [create a deployment](https://auth.queryfarm.cloud/console/new?worker=xslt). Hosting has a $10 monthly minimum per organization; usage and license fees may apply. Copy the deployment-specific ATTACH from the console.

## Service credentials and prerequisites

No service credentials are declared by this connector. Individual datasets, input files or deployments may have their own prerequisites.

Secret parameter required flags describe the upstream declaration; they do not override the service-level mode above. Keep secrets in environment variables or the deployment secret store. SQL values in angle brackets are placeholders, not automatic environment lookups. Native DuckDB and Haybarn 2.0.1 do not provide a SQL getenv() function, even when worker-supplied snippets mention it. Read environment variables in your application and pass credential values through client parameter bindings (for example, Python con.execute("CREATE SECRET stripe (TYPE stripe, api_key ?)", [os.environ["STRIPE_API_KEY"]]) after attaching the connector. Omit unused optional parameters and keep real values out of saved SQL and logs.

## Install the extension

In stock DuckDB:

```sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;
```

In Haybarn:

```sql
INSTALL vgi FROM community;
LOAD vgi;
```

## Attach the connector

The local recipes below pin the catalog release for repeatability. A public demo endpoint follows its deployed release.

### uvx

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

```sql
ATTACH 'xslt' AS xslt (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/vgi-xslt@v0.5.0 vgi-xslt-worker'
);
```

### Docker

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

```sql
ATTACH 'xslt' AS xslt (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-xslt:0.5.0'
);
```

## Explode a document into numbered (seq, value) rows in document order.

Service credentials required for this example: not declared by this example; check the connector requirements above.

```sql
SELECT seq, value FROM xslt.main.xpath_nodes('<r><i>a</i><i>b</i></r>', '//i') ORDER BY seq
```

- [xslt.main.xpath_nodes — table_function](https://query.farm/products/orchard/connectors/xslt/objects/table_function.bWFpbg.eHBhdGhfbm9kZXM.md): exact declaration for this example.

Execution evidence: **captured_result**.

```json
{
  "status": "captured_result",
  "capturedAt": "2026-12-01T06:24:17+00:00",
  "engineVersion": "2.0.1",
  "protocolVersion": "3.4.0",
  "releaseTag": "v0.5.0",
  "sample": {
    "columns": [
      "seq",
      "value"
    ],
    "types": [
      "BIGINT",
      "VARCHAR"
    ],
    "rows": [
      [
        1,
        "a"
      ],
      [
        2,
        "b"
      ]
    ],
    "more": false
  }
}
```

## Connector reference

### XSLT, XQuery & XPath for XML in SQL

![Saxonica SaxonC-HE logo](https://avatars.githubusercontent.com/u/3630933?s=240&v=4)

Transform, query, and shred XML directly in DuckDB SQL with full **XSLT 3.0**, **XQuery 3.1**, and **XPath 3.1** support, powered by the production-grade Saxon processor.

This extension turns DuckDB into an XML processing engine. Instead of exporting data to a separate XSLT/XQuery toolchain, you can apply stylesheets, evaluate XPath expressions, run XQuery FLWOR programs, and explode XML documents into relational rows without ever leaving SQL. It is built for data engineers and analysts who land XML in columns -- SOAP/EDI payloads, RSS/Atom feeds, OOXML and SVG fragments, scientific and financial document formats -- and need to extract, reshape, or validate that markup at query time, row by row, with NULLs passed through cleanly.

## Key concepts

- **Per-row scalars vs. set-returning table functions.** Scalars compute one value per row (a string, boolean, number, or list); table functions and the array-plus-UNNEST pattern explode a single document into many rows -- the natural way to *shred* XML into a relational result.
- **Transform, query, and validate.** XSLT reshapes documents, XPath and XQuery pull values out of them, and a well-formedness check lets you filter malformed rows before processing.
- **NULL / invalid / error.** A NULL input yields NULL output (or no rows); malformed XML or a bad stylesheet/expression raises a clean DuckDB error, so bad data never crashes the worker.

## When to use it

Reach for this worker whenever XML lands in a DuckDB column and you need to read a value out of it, transform it into another shape, or normalize its repeated structure into rows for downstream SQL.

## Under the hood

The worker is backed by [SaxonC-HE](https://www.saxonica.com/), the free Home Edition of [Saxonica](https://www.saxonica.com/)'s Saxon processor -- the reference implementation for XSLT 3.0 / XQuery 3.1 / XPath 3.1 -- via the [saxonche](https://pypi.org/project/saxonche/) Python bindings. A single native Saxon processor is booted once per worker and reused; compiled stylesheets and queries are cached on their source text, so a constant stylesheet applied down a column compiles once and transforms many rows. Note that SaxonC-HE is not schema-aware, so there is no XSD validation; the well-formedness check provides the strongest guarantee the free edition offers.

## Learn more

- [Saxonica homepage](https://www.saxonica.com/)
- [Saxon documentation](https://www.saxonica.com/documentation/index.html)
- [Saxon-HE source on GitHub](https://github.com/Saxonica/Saxon-HE)
- [`saxonche` on PyPI](https://pypi.org/project/saxonche/)
- W3C specs: [XSLT 3.0](https://www.w3.org/TR/xslt-30/), [XPath 3.1](https://www.w3.org/TR/xpath-31/), [XQuery 3.1](https://www.w3.org/TR/xquery-31/)

## Find the exact SQL object

[Browse 10 object declarations](https://query.farm/products/orchard/api/v1/connectors/xslt/objects.json) or [search within this connector](https://query.farm/products/orchard/api/v1/search.json?kind=object&connector=xslt&q=xslt).

Follow one format of each needed object for complete argument types, defaults, named flags, return columns and examples. Existing links above can replace another search. For questions about hosting, credentials or supported operations, stop once the documentation answers the question; SQL and unrelated object lookups are unnecessary.

## Verification and interpretation

- Missing, null, or undeclared metadata means unknown; do not invent defaults, credential scope, platform support or endpoint URLs.
- Search is keyword retrieval, not proof of a capability. Read the exact object declaration before generating SQL.
- A table and a table function can have the same name. Preserve parentheses and use the matching overload and schema.
- Service credentials, external data availability and deployment authentication are separate requirements.
- Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL.

```json
{
  "generatedAt": "2026-12-01T18:22:16+00:00",
  "repository": "https://github.com/Query-farm/vgi-xslt",
  "harvest": {
    "status": "ok",
    "method": "subprocess",
    "error": null,
    "vgi_version": "9773130dde"
  },
  "catalogVerification": {
    "verified": true,
    "status": "passed",
    "total": 2,
    "passed": 2,
    "failed": 0,
    "needs_credentials": 0,
    "location": "uvx --from git+https://github.com/Query-farm/vgi-xslt@v0.5.0 vgi-xslt-worker",
    "transport": "subprocess",
    "environment": {
      "vgi_extension_version": "9773130dde",
      "haybarn_version": "2.0.1rc3",
      "engine_version": "v2.0.1",
      "python": "3.12.4",
      "platform": "darwin_arm64",
      "protocol_version": "3.4.0"
    },
    "checked_at": "2026-12-01T06:22:19+00:00"
  },
  "interpretation": "Catalog verification records the harvest environment. It is not proof that every query or current live API call succeeds. Only an example with captured_result has a saved result for that exact SQL."
}
```
