XAODocs · v1.0.0-dev

Core Concepts · 2 min read

Architecture & XML Aggregation

How Xao builds a unified XML conglomeration document from databases, Markdown, and domain objects before delegating presentation to XSLT 3.0.

  • architecture
  • aggregation
  • domdoc
  • appdoc

Xao is built around a single unifying architectural thesis: every request constructs one well-formed XML conglomeration document by aggregating heterogeneous data sources into a single DOM tree, then transforms that tree into the final representation via XSLT 3.0.

  Relational DB (PDO / DbToXml) ──┐
  Static / File XML Fragments  ───┼──▶  DomDoc / AppDoc  ──▶  XsltDriverInterface (XSLT 3.0)  ──▶  HTML / XML / RSS / JSON
  External Feeds & HTTP APIs   ───┤    (Conglomeration)         • PhcNativeXsltDriver (default, built-in xee-xslt)
  Domain DomDoc Objects        ───┤                             • SaxonHttpDriver (HTTP / distributed)
  Markdown to XML (CommonMark) ───┘                             • ClientSideXslDriver (fallback)

Why XML Conglomeration Works

  1. One data boundary, many outputs: Because PHP produces a clean XML tree rather than concatenating HTML strings, the exact same DomDoc can render HTML5, Atom/RSS, SVG, print-ready specs, or raw XML without changing PHP controllers.

  2. True separation of concerns: PHP handles authentication, database queries, slug validation, Markdown parsing, and error normalization. XSLT 3.0 handles layout, grouping, navigation highlights, and accessibility landmarks.

  3. Inspectable page state: During development or via dedicated endpoints like /xml/{slug} in XaoDocs, the entire request model is inspectable as a single XML artifact.

  4. Stateless worker safety: AppDoc and DocsApp hold zero mutable per-request static state, allowing phc serve mode = "worker" to reuse booted PHP workers across thousands of requests with zero state leakage.

Core Building Blocks

ComponentResponsibility
Xao\XaoRootStructured, inspectable error tracking (addError, addException, hasErrors) without silent failures
Xao\DomDocStrict PHP 8 DOMDocument / DOMXPath wrapper for tree construction, XML/file consumption, namespace-aware nodes, and <error> generation
Xao\DomFactorySafe entrypoints (fromXml, fromFile, fromRoot) enforcing XXE/DOCTYPE rejection and realpath() containment
Xao\DbToXmlSerializes PDO queries, PDOStatement, and iterables into clean <result><row> XML trees
Xao\AppDocStateless front controller pairing routes, gated debug output (?xao:XML=1), and XSLT 3.0 drivers
Xao\Xslt\TransformerEnforces stylesheet-root realpath() containment and delegates rendering to XsltDriverInterface

Explicit Non-Goals

Xao intentionally avoids competing with full-stack ecosystems like Laravel or Symfony:

  • No backwards compatibility with PHP 4 domxml, Sablotron xslt_*, or PEAR DB.

  • No Composer runtime dependency tree in core src/.

  • No unsafe C libxslt FFI bindings inside PHC (#![forbid(unsafe_code)]).