XPath, XQuery, and XSLT for Rust
Pronounced “crust”.
The goal of this project is to implement XPath 3.1, XQuery 3.1 and XSLT 3.0 in Rust. Also included is an XML parser, using a parser combinator inspired by Nom.
Currently the project is a proof-of-concept. There is a rudimentary implementation of the XQuery and XPath Data Model 3.1, along with an implementation of XPath which, roughly speaking, conforms to version 1.0 (with a few other features, such as FLWR expressions). The XSLT implementation can evaluate basic XSL stylesheets, but is still incomplete wrt the XSLT v1.0 specification.
The library separates parsing from evaluation. The XPath and XSLT are parsed (or “compiled”) into an internal representation, a “transformation”, which is then evaluated.
This means it won’t matter how an expression is written; it will be compiled into the same internal form. For example, the XPath expression:
if $a then "a is true" else ""
will result in the same internal format as:
<xsl:if test="$a">
a is true
</xsl:if>
This approach means that the XPath and XSLT modules are simply mappings from their respective syntaxes to an χrust transformation.
NB. We’re picking the low-hanging fruit first. So major, fundamental features of the languages are being implemented to begin with. The fine detail will be added later. So although we’re aiming for v1.0 functionality as a baseline, the eventual desire to implement all of v3.0 dictates that some more advanced features will be implemented sooner rather than later.
See the XSLT module for an example of how to evaluate an XSL stylesheet.
Status of docs/compliance.md with XDM, XPath, XQuery, and XSLT.