XSLT 3.0 Drivers
Pluggable XsltDriverInterface strategies: PhcNativeXsltDriver (default in-process), SaxonHttpDriver (HTTP/distributed), and ClientSideXslDriver.
Xao\Xslt\XsltDriverInterface decouples application logic from the underlying XSLT 3.0 execution strategy via a single stateless method:
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())
$transformer = Transformer::createDefault($stylesheetRoot, $sidecarUrl, $forcedDriver);
Selection order:
Explicit override (
$forcedDriverorXAO_XSLT_DRIVER:'native','saxon', or'client').PhcNativeXsltDriverwhenextension_loaded('xsl') && class_exists('XSLTProcessor')is true (default on PHC).SaxonHttpDriverwhen a$sidecarUrlis provided.ClientSideXslDriverfallback.
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:
Runs completely in-process with zero external sidecar and
allow_network = false.Enforces
realpath()stylesheet-root containment and rejects<!DOCTYPE/<!ENTITY.Passes scalar/null parameters via
XSLTProcessor::setParameter('', $name, $value).Wraps all failures in
Xao\Exceptions\XsltTransformException.
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.