XMLTX - XML Transaction Engine

A pure XML + XSLT web application framework with event sourcing

Architecture

Framework Features

Usage

            
require_once 'xmltx.php';

$app = new XMLTX('data.xml');
$app->handleRequest();
        
          

XSLT Application Logic

The entire web application is defined in XSLT templates. The framework builds a combined XML document containing your data plus HTTP request information:

festival
films
film id "film-1"
title
The Vanishing Coast
director
Anna Bergman
http:request
method
GET
uri
/films/film-1
path
/films/film-1
route
films segment "films"
n1 segment "film-1"

Your XSL templates match routes and generate responses:

xsl:stylesheet version "1.0"
xsl:template match "/"
response
xsl:choose
xsl:when test "$method = 'POST'"
xsl:apply-templates select "$post" mode "post"
xsl:otherwise
xsl:apply-templates select "$request/route" mode "get"
xsl:template match "route[films/*[not(edit)]]" mode "get"
xsl:variable name "id" select "films/*/@segment"
xsl:variable name "film" select "//film[@id=$id]"
html
head
title
xsl:value-of select "$film/title"
body
h1
xsl:value-of select "$film/title"
p
Director:
xsl:value-of select "$film/director"
xsl:template match "post[action='add-film']" mode "post"
x:put target "//films" swap "beforeend"
film id "film-{generate-id()}"
title
xsl:value-of select "title"
director
xsl:value-of select "director"

Key concepts:

Routing System

Common routing patterns and their XSLT templates:

templates
xsl:template match "route[root]" mode "get"
html
body
h1
Welcome
xsl:template match "route[films[not(*)]]" mode "get"
html
body
h1
All Films
xsl:for-each select "//film"
p
xsl:value-of select "title"
xsl:template match "route[films/*/edit]" mode "get"
html
body
h1
Edit Film
form method "post" action "/films/{films/*/@segment}"
input name "action" value "update-film" type "hidden"
input name "title" placeholder "Film Title"
button type "submit"
Update

Route matching patterns:

XML Mutations

Templates generate XML mutations for data updates:

mutations
x:put target "//films" swap "beforeend"
film id "film-new"
title
New Documentary
director
Jane Smith
duration
95
x:put target "//film[@id='film-1']/title" swap "outerHTML"
title
Updated Title
x:rm target "//film[@id='film-old']"
x:mv target "//film[@id='film-2']" destination "//archive"

Mutation operations:

Why XMLTX?