Contents
Getting started
- Install: Cargo, or from source
- Requirements: toolchain floor, platforms
- Quick Start: a query in one line
The oxml-cli ecosystem
- The oxml-cli ecosystem: oxml, xmlschema, oxml-cli, oxml-wasm, oxml-mcp, oxml-lsp, oxml-json
Library reference
- Capabilities at a glance: the current surface by theme
- Ecosystem comparison: short matrix; full table at
doc/COMPARISON.md - Benchmarks: paired comparisons; methodology in oxml's
BENCHMARKS.md - Features: commands, options, exit status, standard input
- Configuration: there is none, and why
- Examples: runnable example index
Operational
- When not to use oxml-cli: limitations
- Development: make targets, fuzzing, CI
- Security: guarantees and compliance
- Documentation: all reference docs
- Stability guarantees: SemVer axis, output stability, minimum toolchain discipline
- License
Install
As a Rust library
[]
= "0.0.17"
The library exposes oxml_cli::run, which the binary, the tests and
the benchmarks all drive. Most users want the binary:
From source:
The binary is called oxml.
Requirements
- Rust 1.89.0 or later. CI builds on exactly that version on every
push; see
doc/POLICIES.md. - No C dependencies and no build toolchain beyond Cargo. If
cargoworks, this installs. - Platforms: CI builds and tests on Linux, macOS and Windows.
Quick Start
)
query evaluates XPath 1.0, check reports well-formedness with a
line and column, and stats summarises what is in a file before you
write a query against it.
The oxml-cli ecosystem
All seven crates ship one version number, moving in steps of 0.0.1.
oxml-cli pins its oxml and xmlschema dependencies to exact
versions with =, and no other combination is supported.
| Component | Purpose | Use case |
|---|---|---|
oxml |
Parser, tree, XPath 1.0 | Reading XML from Rust |
xmlschema |
XSD validation | Checking a document against a schema |
oxml-cli |
The command line | Querying and checking XML in a shell or CI |
oxml-wasm |
WebAssembly bindings | XML in a browser or JavaScript runtime |
oxml-mcp |
Model Context Protocol server | Giving an agent XML tools |
oxml-lsp |
XML analysis and linting | Editor diagnostics |
oxml-json |
JSON support for the language server | Protocol messages for oxml-lsp |
Capabilities at a glance
| Area | Capability | Status |
|---|---|---|
| Query | XPath 1.0: ten axes, 25 functions, all four value types | Available |
| Query | Text-only (-t) and count-only (-c) output |
Available |
| Query | Namespace prefixes bound on the command line (-n, --ns) |
Available |
| Validation | XSD validation via xmlschema |
Available |
| Inspection | Well-formedness with line and column | Available |
| Inspection | Node counts by kind, and maximum depth | Available |
| Input | Standard input; UTF-8, UTF-16 and ISO-8859-1 | Available |
| Scripting | Exit codes that separate "no match" from "usage error" | Available |
| Output | Formatting or pretty-printing | Not yet |
| Output | Editing, XInclude, XSLT | Not yet |
Ecosystem comparison
oxml is measured against xmllint, the tool it is most often used in
place of, and against xmlstarlet, which shows how much a command-line
XML tool can do.
| Project | XSD validation | Single static binary | Fetches external entities |
|---|---|---|---|
| oxml-cli | Yes | Yes | Never |
xmllint |
Yes | No (libxml2) | Configurable |
xmlstarlet |
Yes | No (libxml2) | Configurable |
See doc/COMPARISON.md for the evidence and complete matrix.
Benchmarks
Timings are per invocation with process spawn excluded, because spawn is the operating system's business and swamps everything else on a small document. No absolute throughput figure is published: the same benchmark binary measured 14.7 and 123.1 MB/s on one machine on one day, at a load average above 30. The benchmark reports paired comparisons instead.
| Scenario | Result | Environment |
|---|---|---|
| Argument handling and file I/O over the bare parse | about 9% | 200 KB document, spawn excluded |
--help |
under 1 µs | spawn excluded |
See oxml's BENCHMARKS.md for methodology and full results.
Features
query <XPATH> [FILE]
Evaluate an XPath 1.0 expression.
<title>Dune</title>
<title>Germinal</title>
By default each match is printed as a summary of the node. -t prints
the text instead, and -c prints only how many matched. Non-node
results (numbers, strings, booleans) are printed directly:
validate <XSD> [FILE]
Validate against an XML Schema.
Exit status 0 means the document conforms, 1 means it does not. The schema comes first because the document is the argument that defaults to standard input.
stats [FILE]
Summarise the document: node counts by kind, and maximum depth. Useful for finding out what is in a file before writing a query against it, and for spotting a document that is deeper or larger than expected.
check [FILE]
Report whether the document is well-formed.
The position is a line and column, counted in characters, so it points where an editor would.
Options
| Option | Effect |
|---|---|
-t, --text |
Print matched nodes' text rather than a summary |
-c, --count |
Print only the number of matches |
-n, --ns P=URI |
Bind a namespace prefix for query; repeatable |
-h, --help |
Usage |
-V, --version |
Version |
-t and -c apply to query. Both accept the flag anywhere in the
argument list. An unbound prefix is an error, not a silent match on the
local part; see doc/NAMESPACES.md.
Exit status
| Code | Meaning |
|---|---|
| 0 | Success; for validate, the document conforms |
| 1 | The document is invalid, or no nodes matched |
| 2 | A usage or I/O error |
The distinction between 1 and 2 is the point. A shell script that tests
if oxml query ... ; then wants to know "did anything match", and it
must not confuse that with "you passed a path that does not exist". A
tool that returns 1 for both makes set -e a liability.
if ; then
fi
Reading from standard input
FILE defaults to standard input, so oxml composes:
|
|
Configuration
There is none. No config file, no environment variables, no dotfile.
That is a decision rather than an omission: a command whose behaviour
depends on a file somewhere in your home directory behaves differently
in CI than on your laptop, and the difference surfaces as a confusing
failure. Everything oxml does is on the command line.
File and stdin reads stop at 8 MiB. Parsing and XPath compilation use
Limits::strict(); each query uses EvalLimits::default() to bound
work, intermediate nodes and strings. Exceeding a budget is an error,
not a partial result.
Examples
Runnable scripts live in examples/, each with the sample
document it operates on. They run in CI, so they cannot rot.
| Example | What it shows |
|---|---|
query-basics.sh |
Every output mode of query |
pipeline.sh |
Standard input, exit codes, composing with other tools |
inspect.sh |
stats and check, including a malformed document |
validate.sh |
XSD validation, valid and invalid |
Coming from another tool:
doc/MIGRATION-FROM-XMLLINT.md maps
xmllint and xmlstarlet commands to oxml, and
doc/USER-GUIDE.md collects recipes.
When not to use oxml-cli
- You need to edit XML.
xmlstarlet eddoes; this does not. - You need to format or pretty-print.
xmllint --formatdoes. - You need XSLT.
xsltproc. - You need XPath 2.0 or 3.1. This is 1.0, so no
matches(), nofor, no sequences. - The document is larger than memory. The whole tree is built, and reads stop at 8 MiB.
Development
make gate runs scripts/gate.sh: the workflow contract tests,
format, clippy, tests, rustdoc, the complexity ratchet, the
#![forbid(unsafe_code)] check, the examples, the 95% coverage floor,
the published-figures and package checks, and an MSRV build. It pins
the toolchain rather than trusting rust-toolchain.toml, because a
RUSTUP_TOOLCHAIN in the environment silently overrides that file.
Fuzz targets live in fuzz/ and run in CI. CI also runs the
test suite on Linux, macOS and Windows.
Security
The parser underneath never dereferences external entities, so XXE is
foreclosed structurally rather than by a default: a document containing
<!ENTITY xxe SYSTEM "file:///etc/passwd"> cannot make oxml read
that file. Entity expansion is bounded. There is no network code in the
dependency tree. The crate is #![forbid(unsafe_code)].
Scorecard scans use a digest-pinned upstream image. Results are retained
as CI artifacts and repository posture findings in GitHub code scanning,
not published to Scorecard's public service. The badge shows workflow
status, not a security score; a successful scan can still report findings.
The project holds an
OpenSSF Best Practices
badge. The threat model is in
doc/SECURITY-MODEL.md and the argument for
it in doc/ASSURANCE-CASE.md.
Report vulnerabilities according to SECURITY.md.
Documentation
doc/: the decisions, in longer formdoc/USER-GUIDE.md: recipesdoc/FAQ.md: frequently asked questionsdoc/ARCHITECTURE.md: how the binary is put togetherdoc/COMPARISON.md: againstxmllint,xmlstarletandxq- docs.rs/oxml-cli: the library API
- oxml's documentation
CHANGELOG.mdandCONTRIBUTING.md
Stability guarantees
- Versioning. The family moves in steps of 0.0.1 and every member
ships the same version. Before 0.1.0, any release may change the
command line; changes are listed in
CHANGELOG.md. - Output.
query -tandquery -care stable enough to parse: one result per line, nothing else on stdout.statsand the defaultqueryoutput are human-facing and may change. - Exit codes. 0, 1 and 2 keep the meanings in Exit status.
- Minimum toolchain. Rust 1.89.0, enforced in CI on every push. The
floor moves with the family and is recorded in the CHANGELOG; see
doc/POLICIES.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
oxml-cli is measured against
xmllint, the reason the
exit-code behaviour is what it is; owes the idea of how much a
command-line XML tool can do to
xmlstarlet; and holds itself to
the standard jq set for
pipeline-friendly query tools.