xml-adapters
roxmltree adapters for relax-ng, xpath-eval and schematron-engine: validate an XML file in a few lines.
relax-ng, xpath-eval and schematron-engine take documents through traits and parse none
themselves. This crate implements those traits for roxmltree, so a host that has XML text
validates it against a RELAX NG and a Schematron schema without writing the glue first. It sits
in L1 because it knows the L0 traits; the L0 crates do not know it (rule “no host format in the
core”), apart from a dev-dependency of xpath-eval’s tests.
Status
0.1.0, not yet published. The first version of a new crate has to be published by hand (see
Releases). Only roxmltree; other trees (xmltree, quick-xml DOMs) are
open under casoon/barrierlab#75.
Structure
Public surface
RngElement(featurerelax-ng):relax_ng::Elementover aroxmltreeelement. Text is merged across comments and processing instructions,xmlnsdeclarations are not attributes, bindings in scope (inherited too) serveQNamevalues.XmlDoc,XmlNode(featurexpath): an arena copy of the tree in document order implementingxpath_eval::DocumentandNode. Namespace axis with the implicitxmlnode, attribute nodes, comments, processing instructions, empty namespace URI as “none”,xml:idas ID attribute.XmlDoc::parse(&str)orXmlDoc::from_roxmltree(&Document)for other parser options.Position: line and column from 1, byte offset from 0. It is theLocationofRngElement(so arelax_ng::ValidationErrorcarries it) andXmlNode::position()(so a SchematronReport::nodehas it).
Limits
roxmltreeexposes no DTD attribute types, soid()findsxml:idonly.- Positions are those of the start tag’s
<; text, attribute and comment nodes have none. xpath-eval’s own tests useXmlDocthrough a path-only dev-dependency that loops back toxpath-eval. Cargo allows this for dev-dependencies and drops the entry when packaging; the packaged tests ofxpath-evaltherefore do not build outside this repository.
Verification
crates/xml-adapters/tests/validate.rs: one document against an RNG and a Schematron schema
(valid, invalid, positions), the namespace axis, comments, processing instructions, xml:id and
document order, plus the README example as a doctest. The Jaxen and regression suites of
xpath-eval run over this adapter.