<?xml version="1.0" encoding="UTF-8"?>
<xao-docs>
  <site name="XaoDocs" product="Xao" version="1.0.0-dev" homepage="https://xao.ndx.au" repo="https://github.com/ndx-au/Xao" examples-repo="https://github.com/ndx-au/xao-example-apps"/>
  <request slug="xslt-drivers" theme="atlas" path="/xml/xslt-drivers" xml-url="/xml/xslt-drivers"/>
  <themes>
    <theme id="atlas" name="Atlas" tagline="Three-column reference desk with persistent sidebar and sticky page outline" audience="API and framework developers browsing across sections" structure="3-column grid: left navigation sidebar, center article, right on-this-page outline" css="/assets/atlas.css" active="true"/>
    <theme id="folio" name="Folio" tagline="Editorial journal spread with XPath-grouped numbered chapters and collapsible library" audience="Architects and evaluators reading long-form conceptual chapters" structure="Editorial cover header, collapsible library drawer, and sibling-grouped numbered chapter sections" css="/assets/folio.css" active="false"/>
    <theme id="console" name="Console" tagline="Operations dashboard with telemetry strip and collapsible H2 module accordions" audience="SREs, operators, and runtime engineers scanning sections quickly" structure="Command header, telemetry bar, compact nav rail, and expandable &lt;details&gt; module accordions" css="/assets/console.css" active="false"/>
    <theme id="reader" name="Reader (A11y)" tagline="WCAG AAA single-column linear reader with upfront summary, numbered TOC, and zero JS" audience="Screen reader users, keyboard-only navigation, and low-vision / cognitive accessibility" structure="Multi-landmark skip links, upfront document summary, inline numbered TOC, figure-wrapped code blocks, directory after article, zero JS" css="/assets/reader.css" active="false"/>
    <theme id="handbook" name="Handbook" tagline="Single-column print-ready technical specification sheet with metadata ledger" audience="Technical reviewers, auditors, and print/PDF export workflows" structure="Single-column specification document with &lt;dl&gt; metadata ledger, numbered outline, and print stylesheet" css="/assets/handbook.css" active="false"/>
  </themes>
  <navigation>
    <section name="Start Here">
      <item slug="index" title="Xao Documentation" description="XML Application Objects for PHP 8 and PHC — zero-dependency XML content aggregation and XSLT 3.0 presentation." order="1" active="false"/>
      <item slug="getting-started" title="Getting Started" description="Set up PHC, autoload Xao with zero Composer packages, transform your first DomDoc with XSLT 3.0, and run phc serve." order="2" active="false"/>
    </section>
    <section name="Core Concepts">
      <item slug="architecture" title="Architecture &amp; XML Aggregation" description="How Xao builds a unified XML conglomeration document from databases, Markdown, and domain objects before delegating presentation to XSLT 3.0." order="3" active="false"/>
      <item slug="xslt-themes" title="XSLT 3.0 Themes vs CSS Skins" description="Why XSLT themes are structurally and semantically richer than CSS-only themes — including accessibility-first DOM transformations." order="4" active="false"/>
    </section>
    <section name="Framework Reference">
      <item slug="core-api" title="Core API Reference" description="Reference for Xao\\Runtime, Xao\\XaoRoot, Xao\\DomDoc, Xao\\DomFactory, Xao\\AppDoc, Xao\\Http\\Response, and Xao\\Exceptions." order="5" active="false"/>
      <item slug="database-aggregation" title="Database Aggregation (DbToXml)" description="Convert PDO queries, PDOStatement results, and PHP iterables directly into structured DomDoc XML fragments under PHC." order="6" active="false"/>
      <item slug="markdown-aggregation" title="Markdown Aggregation" description="Convert CommonMark and GFM into CommonMark XML 1.0 natively in PHC via comrak and graft it into Xao DomDoc trees." order="7" active="false"/>
      <item slug="xslt-drivers" title="XSLT 3.0 Drivers" description="Pluggable XsltDriverInterface strategies: PhcNativeXsltDriver (default in-process), SaxonHttpDriver (HTTP/distributed), and ClientSideXslDriver." order="8" active="true"/>
    </section>
    <section name="Operations &amp; Runtime">
      <item slug="phc-runtime" title="PHC Runtime &amp; Compatibility" description="Running Xao on PHC in isolate and worker modes, sandbox defaults, worker-safe autoloading, and P00–P05 compatibility findings." order="9" active="false"/>
      <item slug="security" title="Security Model" description="XXE rejection, realpath containment, strict slug allowlists, CSRF guards, gated debug output, and PHC sandbox enforcement." order="10" active="false"/>
    </section>
    <section name="Examples &amp; Design">
      <item slug="reference-apps" title="Reference Applications" description="Comparing Xao's built-in SQLite PDO catalog reference app with XaoDocs, the flat-file Markdown multi-theme CMS." order="11" active="false"/>
      <item slug="adr-0001-phc-xee-xslt" title="ADR 0001 &amp; Roadmap" description="Architecture Decision Record for pure-Rust xee-xslt in PHC plus the Xao v1.0.0 milestone and phase roadmap (M0–M3, P00–P06)." order="12" active="false"/>
    </section>
  </navigation>
  <page slug="xslt-drivers" title="XSLT 3.0 Drivers" description="Pluggable XsltDriverInterface strategies: PhcNativeXsltDriver (default in-process), SaxonHttpDriver (HTTP/distributed), and ClientSideXslDriver." section="Framework Reference" audience="Platform and framework engineers" status="stable" words="237" reading-minutes="2" source-file="content/xslt-drivers.md">
    <tags>
      <tag>xslt3</tag>
      <tag>drivers</tag>
      <tag>xee-xslt</tag>
      <tag>saxon</tag>
    </tags>
    <neighbors>
      <prev slug="markdown-aggregation" title="Markdown Aggregation"/>
      <next slug="phc-runtime" title="PHC Runtime &amp; Compatibility"/>
    </neighbors>
    <body>
      <document xmlns="http://commonmark.org/xml/1.0">
        <heading level="1">
          <text xml:space="preserve">XSLT 3.0 Drivers</text>
        </heading>
        <paragraph>
          <code xml:space="preserve">Xao\Xslt\XsltDriverInterface</code>
          <text xml:space="preserve"> decouples application logic from the underlying XSLT 3.0 execution strategy via a single stateless method:</text>
        </paragraph>
        <code_block info="php" xml:space="preserve">namespace Xao\Xslt;

interface XsltDriverInterface
{
    public function transform(string $xml, string $stylesheetPath, array $params = []): string;
}
</code_block>
        <paragraph>
          <code xml:space="preserve">Xao\Xslt\Transformer</code>
          <text xml:space="preserve"> wraps any </text>
          <code xml:space="preserve">XsltDriverInterface</code>
          <text xml:space="preserve"> implementation and enforces strict </text>
          <code xml:space="preserve">realpath()</code>
          <text xml:space="preserve"> containment inside the configured </text>
          <code xml:space="preserve">$stylesheetRoot</code>
          <text xml:space="preserve"> before delegating transformation.</text>
        </paragraph>
        <heading level="2">
          <text xml:space="preserve">Driver Selection (</text>
          <code xml:space="preserve">Transformer::createDefault()</code>
          <text xml:space="preserve">)</text>
        </heading>
        <code_block info="php" xml:space="preserve">$transformer = Transformer::createDefault($stylesheetRoot, $sidecarUrl, $forcedDriver);
</code_block>
        <paragraph>
          <text xml:space="preserve">Selection order:</text>
        </paragraph>
        <list type="ordered" start="1" delim="period" tight="true">
          <item>
            <paragraph>
              <text xml:space="preserve">Explicit override (</text>
              <code xml:space="preserve">$forcedDriver</code>
              <text xml:space="preserve"> or </text>
              <code xml:space="preserve">XAO_XSLT_DRIVER</code>
              <text xml:space="preserve">: </text>
              <code xml:space="preserve">'native'</code>
              <text xml:space="preserve">, </text>
              <code xml:space="preserve">'saxon'</code>
              <text xml:space="preserve">, or </text>
              <code xml:space="preserve">'client'</code>
              <text xml:space="preserve">).</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">PhcNativeXsltDriver</code>
              </strong>
              <text xml:space="preserve"> when </text>
              <code xml:space="preserve">extension_loaded('xsl') &amp;&amp; class_exists('XSLTProcessor')</code>
              <text xml:space="preserve"> is true (default on PHC).</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">SaxonHttpDriver</code>
              </strong>
              <text xml:space="preserve"> when a </text>
              <code xml:space="preserve">$sidecarUrl</code>
              <text xml:space="preserve"> is provided.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <strong>
                <code xml:space="preserve">ClientSideXslDriver</code>
              </strong>
              <text xml:space="preserve"> fallback.</text>
            </paragraph>
          </item>
        </list>
        <heading level="2">
          <code xml:space="preserve">PhcNativeXsltDriver</code>
          <text xml:space="preserve"> (Primary Default)</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">Source: </text>
          <code xml:space="preserve">src/Xslt/PhcNativeXsltDriver.php</code>
        </paragraph>
        <paragraph>
          <text xml:space="preserve">Wraps PHC's built-in </text>
          <code xml:space="preserve">XSLTProcessor</code>
          <text xml:space="preserve"> (</text>
          <code xml:space="preserve">xsl3</code>
          <text xml:space="preserve">, backed by pure-Rust </text>
          <code xml:space="preserve">xee-xslt</code>
          <text xml:space="preserve"> and </text>
          <code xml:space="preserve">xot</code>
          <text xml:space="preserve"> with </text>
          <code xml:space="preserve">#![forbid(unsafe_code)]</code>
          <text xml:space="preserve">) or PHP 8.4's </text>
          <code xml:space="preserve">ext-xsl</code>
          <text xml:space="preserve">:</text>
        </paragraph>
        <list type="bullet" tight="true">
          <item>
            <paragraph>
              <text xml:space="preserve">Runs completely in-process with zero external sidecar and </text>
              <code xml:space="preserve">allow_network = false</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Enforces </text>
              <code xml:space="preserve">realpath()</code>
              <text xml:space="preserve"> stylesheet-root containment and rejects </text>
              <code xml:space="preserve">&lt;!DOCTYPE</code>
              <text xml:space="preserve"> / </text>
              <code xml:space="preserve">&lt;!ENTITY</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Passes scalar/null parameters via </text>
              <code xml:space="preserve">XSLTProcessor::setParameter('', $name, $value)</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
          <item>
            <paragraph>
              <text xml:space="preserve">Wraps all failures in </text>
              <code xml:space="preserve">Xao\Exceptions\XsltTransformException</code>
              <text xml:space="preserve">.</text>
            </paragraph>
          </item>
        </list>
        <heading level="2">
          <code xml:space="preserve">SaxonHttpDriver</code>
          <text xml:space="preserve"> (Distributed / HTTP XSLT)</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">Source: </text>
          <code xml:space="preserve">src/Xslt/SaxonHttpDriver.php</code>
        </paragraph>
        <paragraph>
          <text xml:space="preserve">Sends </text>
          <code xml:space="preserve">{xml, stylesheet, params}</code>
          <text xml:space="preserve"> over </text>
          <code xml:space="preserve">curl_exec()</code>
          <text xml:space="preserve"> to a local or remote HTTP XSLT 3.0 service (for example, </text>
          <code xml:space="preserve">tools/xslt-sidecar/server.py</code>
          <text xml:space="preserve"> backed by SaxonC-HE). Useful for distributed/topological XSLT tiers or full W3C XSLT 3.0 constructs not yet covered by </text>
          <code xml:space="preserve">xee-xslt</code>
          <text xml:space="preserve">. Requires </text>
          <code xml:space="preserve">sandbox.allow_network = true</code>
          <text xml:space="preserve"> in </text>
          <code xml:space="preserve">phc.toml</code>
          <text xml:space="preserve">.</text>
        </paragraph>
        <heading level="2">
          <code xml:space="preserve">ClientSideXslDriver</code>
          <text xml:space="preserve"> (Zero-Infra Fallback)</text>
        </heading>
        <paragraph>
          <text xml:space="preserve">Source: </text>
          <code xml:space="preserve">src/Xslt/ClientSideXslDriver.php</code>
        </paragraph>
        <paragraph>
          <text xml:space="preserve">Injects a </text>
          <code xml:space="preserve">&lt;?xml-stylesheet type="text/xsl" href="..."?&gt;</code>
          <text xml:space="preserve"> processing instruction and sets response </text>
          <code xml:space="preserve">Content-Type</code>
          <text xml:space="preserve"> to </text>
          <code xml:space="preserve">application/xml; charset=utf-8</code>
          <text xml:space="preserve">.</text>
        </paragraph>
      </document>
    </body>
  </page>
</xao-docs>
