From 1202e84d48d9c6c554f4bdf3f4b2fed83976e94c Mon Sep 17 00:00:00 2001 From: Daniel Birket Date: Fri, 20 Aug 2021 23:20:02 -0400 Subject: [PATCH] xml: add select, edit and transform subcommands. --- pages/common/xml-edit.md | 20 ++++++++++---------- pages/common/xml-select.md | 25 +++++++++++-------------- pages/common/xml-transform.md | 20 ++------------------ 3 files changed, 23 insertions(+), 42 deletions(-) diff --git a/pages/common/xml-edit.md b/pages/common/xml-edit.md index b466fe22d1..af75eb5545 100644 --- a/pages/common/xml-edit.md +++ b/pages/common/xml-edit.md @@ -3,25 +3,25 @@ > Edit an XML document. > More information: . -- TBD: +- Delete elements matching an XPATH from an XML document: -`xml edit` +`xml edit --delete {{"XPATH1"}} {{path/to/input.xml|URI}}` -- TBD: +- Move an element node of an XML document from XPATH1 to XPATH2: -`xml edit` +`xml edit --move {{"XPATH1"}} {{"XPATH2"}} {{path/to/input.xml|URI}}` -- TBD: +- Rename all attributes named "id" to "ID": -`xml edit` +`xml edit --rename {{"//*/@id"}} -v {{"ID"}} {{path/to/input.xml|URI}}` -- TBD: +- Rename XML elements of "table" named "rec" to "record": -`xml edit` +`xml edit --rename {{"/xml/table/rec"}} -v {{"record"}} {{path/to/input.xml|URI}}` -- TBD: +- Update the value of XML table record ID=3 to 5: -`xml edit` +`xml edit --update {{"xml/table/rec[@id=3]/@id"}} -v {{5}} {{path/to/input.xml|URI}}` - Display help for the `edit` subcommand: diff --git a/pages/common/xml-select.md b/pages/common/xml-select.md index 8424380dec..39a1c80e64 100644 --- a/pages/common/xml-select.md +++ b/pages/common/xml-select.md @@ -1,27 +1,24 @@ # xml select -> Select from XML documents using XPATH. -> More information: . +> Select from XML documents using XPATHs. +> Tip: use `xml elements` to display the XPATHs of an XML document. +> More information: . -- TBD: +- Select all elements matching "XPATH1" and print the value of the element "XPATH2": -`xml select` +`xml select --template --match {{"XPATH1"}} --value-of {{"XPATH2"}} {{path/to/input.xml|URI}}` -- TBD: +- Match "XPATH1" and print the value of "XPATH2" as text with new-lines: -`xml select` +`xml select --text --template --match {{"XPATH1"}} --value-of {{"XPATH2"}} --nl {{path/to/input.xml|URI}}` -- TBD: +- Count the elements of "XPATH1": -`xml select` +`xml select --template --value-of "count({{XPATH1}})" {{path/to/input.xml|URI}}` -- TBD: +- Count all nodes in XML document(s): -`xml select` - -- TBD: - -`xml select` +`xml select --text --template --inp-name --output " " --value-of "count(node())" --nl {{path/to/input1.xml|URI}} {{path/to/input2.xml|URI}}` - Display help for the `select` subcommand: diff --git a/pages/common/xml-transform.md b/pages/common/xml-transform.md index c9e706dc7a..003ea9cdc5 100644 --- a/pages/common/xml-transform.md +++ b/pages/common/xml-transform.md @@ -3,25 +3,9 @@ > Transform XML documents using XSLT. > More information: . -- TBD: +- Transform an XML document using an XSL stylesheet, passing one XPATH parameter and one literal string parameter: -`xml transform` - -- TBD: - -`xml transform` - -- TBD: - -`xml transform` - -- TBD: - -`xml transform` - -- TBD: - -`xml transform` +`xml transform {{path/to/stylesheet.xsl}} -p {{"Count='count(/xml/table/rec)'"}} -s {{Text="Count="}} {{path/to/input.xml|URI}}` - Display help for the `transform` subcommand: