Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Appendix A: The Command-Line Reference

The full reference of the sxml command, with every option of every command, its exit codes and many examples, is the command's manual, apps/sxml/README.md in the repository. It is also USAGE.md in each release archive, and sxml help COMMAND prints the help of one command.

At a glance:

CommandWhat it doesTaught in
sxml xpath [OPTIONS] EXPRESSIONEvaluates an XPath 4.0 expressionFinding Things with XPath
sxml xquery [OPTIONS] [QUERY-FILE]Runs an XQuery 4.0 query, from a file or --expressionWriting Programs with XQuery
sxml transform [OPTIONS] STYLESHEET [INPUT]Runs an XSLT 4.0 transformationTransforming with XSLT
sxml validate [OPTIONS] FILE...Validates documents against an XSD 1.1 schemaValidating with XSD
sxml check [OPTIONS] FILE...Checks that documents are well-formed, or valid against their DTDThe sxml Command
sxml serialize [OPTIONS] FILEParses a document and writes it againThe sxml Command
sxml versionPrints the version
sxml help [COMMAND]Shows help

The options you'll use most:

OptionCommandsMeaning
--context-item=FILExpath, xqueryThe document the expression starts from
--expression=TEXTxqueryThe query text, instead of a query file
--param=NAME=VALUExpath, xquery, transformBinds $NAME to VALUE as xs:untypedAtomic; an external variable or stylesheet parameter declared with an as type converts it, and text that does not convert is an error (FORG0001 for a query, XTTE0590 for a stylesheet parameter)
--method=METHODxpath, xquery, transform, serializeThe output method: adaptive, xml, xhtml, html, text, json or csv
--output=FILE, -o FILExpath, xquery, transform, serializeWrites the result to a file, only when the command succeeds
--forcethe sameLets --output replace a file that exists
--result-directory=DIRtransformWrites result documents below DIR
--initial-template=NAME, --initial-mode=NAMEtransformWhere the transformation starts
--allow-putxqueryLets fn:put write files
--allow-file-accessxpath, xqueryMakes the EXPath File functions available
--collection=DIRxpath, xquery, transformThe XML files of DIR are the default collection, collection()
--code-language=LIBRARYxpath, xquery, transformLoads a tree-sitter language from a shared library for sxml:parse-code; repeatable
--external-entities, --validate-dtdcheckReads external DTDs and entities; validates against the DTD
--schema=SCHEMAvalidateA schema document; repeat it to combine several into one schema
--use-schema-locationvalidateAlso reads the schema documents a document's xsi:schemaLocation names
--mode=laxvalidateLax validation
--indentserializeIndents the output
--format=jsoncheck, validate, versionA report as JSON, for programs
Exit statusMeaning
0Success
1The operation failed: not well-formed, not valid, or an error in a query or stylesheet
2Usage error
3A file could not be read or written
4An internal error or an exceeded limit