1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-19 18:55:24 +02:00

xml: add select, edit and transform subcommands.

This commit is contained in:
Daniel Birket 2021-08-20 23:20:02 -04:00 committed by Starbeamrainbowlabs
parent 82f626c693
commit 1202e84d48
3 changed files with 23 additions and 42 deletions

View file

@ -3,25 +3,25 @@
> Edit an XML document.
> More information: <http://xmlstar.sourceforge.net/docs.php>.
- 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:

View file

@ -1,27 +1,24 @@
# xml select
> Select from XML documents using XPATH.
> More information: <http://xmlstar.sourceforge.net/doc/xmlstarlet.pdft>.
> Select from XML documents using XPATHs.
> Tip: use `xml elements` to display the XPATHs of an XML document.
> More information: <http://xmlstar.sourceforge.net/docs.php>.
- 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:

View file

@ -3,25 +3,9 @@
> Transform XML documents using XSLT.
> More information: <http://xmlstar.sourceforge.net/docs.php>.
- 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: