xmlstarlet-notes news

Link: https://martin7th.github.io/xmlstarlet-notes/

Version 2023-08-15

XML parsing and serialization

(link) Added example: CDATA can protect against default serialization.

Numeric representation

(link) New entry, with examples of libxml2 numbers in scientific notation.

-L (--inplace) - edit input file(s) in-place

(link) Added:

Add if «condition»

(link) New entry, demonstrating if-then-else logic with xmlstarlet edit.

--xinclude - do XInclude processing on document input

(link) The entire entry on XInclude has been rewritten.

xmlSAX2Characters: huge text node: out of memory

(link) Added error message.

Patch adds --huge and --big-lines options to xmlstarlet

Recently the author of the xmlstarlet-notes document has provided a patch to make xmlstarlet use ‘huge’ nodes and ‘big lines’. It requires the program to be rebuilt from source code.

Quoting from the README:

This patch adds 2 global options to xmlstarlet, available in the subcommands elements, select, edit, format, canonic, validate, and transform:

Version 2023-01-29

Special characters

(link)edit newline variable example changed:

--var nl 'substring-before('"$(printf '"\nA"')"',"A")'

XML parsing and serialization

(link) Added:

The xmlEscapeEntities function in libxml2’s xmlsave.c serialization module gives special treatment to characters &<> (output as &amp;, &lt;, and &gt;) but neither apostrophe nor double quote ('"). xmlstarlet has no option to override this.

Back reference $prev variable

(link) Changed:

The $prev variable refers to a nodeset (changed from ‘node’).

PYX: xmlstarlet pyx, depyx

(link) Added:

a pyx | depyx pipeline does not guarantee an accurate roundtrip

Namespace prefix «name» … is not defined

(link) New entry, dealing with : (colon) in a name when not indicating a namespace prefix.

Context node and current node

(links): select -t (--template) | select -m (--match) | ex4: external lookup table | extract subtree example | xmlstarlet edit | tree height example
Changed:

The current node – part of the XSLT processing model – was referred to as context node – part of the XPath evaluation context. Changed to ‘current node’ as this is more in line with XSLT 1.0 terminology.

Version 2022-10-31

SourceForge now accepts the HTTPS protocol so all remaining HTTP links (xmlstar.sourceforge.net and saxon.sourceforge.net) have been changed to HTTPS.

-q (--quiet): suppress error output

(link) Changes:

Removed: ‘Caution: this option is ignored by xmlstarlet edit.’

Added: Link to format -Q (--quiet) local option.

-Q (--quiet) [undocumented] - suppress error output

(link) New entry:

Does what the -q (--quiet) global option does.

-b (--break) ends current container element

(link) Changes:

Added to the --var without = list item: any nested --vars are local to the enclosing --var but must have unique variable names.

Version 2022-09-30

User’s guide, examples, source code, forums

(link) 2nd and 3rd list item replaced with:

Links to doc/xmlstarlet changed to the latest version at Fossies here: $prev, --var, -L (--inplace), and -E (--embed).

Global options and parameters

(link) Added after 1st paragraph:

An input filename starting with - (dash) – unless it’s short for stdin – must be prefixed with ./ (dot slash) otherwise it will be parsed as an option, possibly causing select (Caution) to ignore the file.

Beware of known bugs for filenames containing (#123 ) ' (single quote), or (#110) urlencoded characters, e.g. %20.

See also: couldn’t read file | failed to load external entity

-L (--inplace) - edit input file in-place

(link) Added as last list item:

couldn’t read file

(new entry)

See failed to load external entity (re stdin)

failed to load external entity

(link) 3rd list item changed to:

Version 2022-09-05

Initial release.