XaoDocs Accessible Linear Edition

Document Summary

XSLT 3.0 Drivers

Pluggable XsltDriverInterface strategies: PhcNativeXsltDriver (default in-process), SaxonHttpDriver (HTTP/distributed), and ClientSideXslDriver.

Section
Framework Reference
Target audience
Platform and framework engineers
Estimated reading time
2 minute(s) (237 words)
Major sections
4

Xao\Xslt\XsltDriverInterface decouples application logic from the underlying XSLT 3.0 execution strategy via a single stateless method:

Code example (php)
namespace Xao\Xslt;

interface XsltDriverInterface
{
    public function transform(string $xml, string $stylesheetPath, array $params = []): string;
}

Xao\Xslt\Transformer wraps any XsltDriverInterface implementation and enforces strict realpath() containment inside the configured $stylesheetRoot before delegating transformation.

Driver Selection (Transformer::createDefault())

Code example (php)
$transformer = Transformer::createDefault($stylesheetRoot, $sidecarUrl, $forcedDriver);

Selection order:

  1. Explicit override ($forcedDriver or XAO_XSLT_DRIVER: 'native', 'saxon', or 'client').

  2. PhcNativeXsltDriver when extension_loaded('xsl') && class_exists('XSLTProcessor') is true (default on PHC).

  3. SaxonHttpDriver when a $sidecarUrl is provided.

  4. ClientSideXslDriver fallback.

PhcNativeXsltDriver (Primary Default)

Source: src/Xslt/PhcNativeXsltDriver.php

Wraps PHC's built-in XSLTProcessor (xsl3, backed by pure-Rust xee-xslt and xot with #![forbid(unsafe_code)]) or PHP 8.4's ext-xsl:

SaxonHttpDriver (Distributed / HTTP XSLT)

Source: src/Xslt/SaxonHttpDriver.php

Sends {xml, stylesheet, params} over curl_exec() to a local or remote HTTP XSLT 3.0 service (for example, tools/xslt-sidecar/server.py backed by SaxonC-HE). Useful for distributed/topological XSLT tiers or full W3C XSLT 3.0 constructs not yet covered by xee-xslt. Requires sandbox.allow_network = true in phc.toml.

ClientSideXslDriver (Zero-Infra Fallback)

Source: src/Xslt/ClientSideXslDriver.php

Injects a <?xml-stylesheet type="text/xsl" href="..."?> processing instruction and sets response Content-Type to application/xml; charset=utf-8.