Getting Started
Build xsql and run your first query.
Build
xsql is a standard Cargo workspace.
cargo build --release # -> target/release/xsqlRun
There are four ways to invoke it:
xsql # interactive REPL
xsql script.xsql # run a script file
xsql -e "USE db.xml SELECT GROUP arms;" # inline query
cat script.xsql | xsql # script piped from stdin
cat db.xml | xsql -e "USE INPUT ..." # XML piped from stdin (filter mode)Your first query
Given a document db.xml:
<Database>
<Group name="goods">
<ItemSpec id="52034301" level="1" cost="500"/>
<ItemSpec id="52034302" level="2" cost="1000"/>
</Group>
</Database>Print every ItemSpec under the goods group whose cost is over 500:
xsql -e '
USE db.xml
SELECT GROUP goods
FOREACH good IN goods
WHERE good.cost > 500
;'Double every item's cost in place:
xsql -e 'USE db.xml UPDATE goods SET cost = cost * 2;'Output goes to stdout: SELECT prints matching elements immediately, and
UPDATE (which mutates the document) causes the whole db.xml document to
be pretty-printed to stdout once the script finishes. Redirect it wherever
you need:
xsql -e 'USE db.xml UPDATE goods SET cost = cost * 2;' > db.xmlNext
Read the CLI reference for REPL details, or jump straight into the language reference.