xml-trim(1) xml-utils xml-trim(1) NAME xml-trim - Trim whitespace in XML elements SYNOPSIS xml-trim [-e ...] [-N ...] [-fnh?] ... DESCRIPTION The xml-trim utility trims whitespace around the text contents of spec‐ ified elements. Whitespace is trimmed according to the following rules: 1. Whitespace characters at the beginning of the first text node child of the specified elements are removed. 2. Whitespace characters at the end of the last text node child of the specified elements are removed. 3. If the -n option is given, sequences of whitespace characters in all text node children of the specified elements are converted to a sin‐ gle space. OPTIONS -e, --element Elements to trim space on. May include a namespace prefix if the namespace was registered with -N. may be either a simple element name (e.g., "para") which matches all elements with the same name at any position, or an XPath expression (e.g., "//section/para") for finer control. -f, --overwrite Overwrite input XML files. -h, -?, --help Show usage message. -N, --namespace Registers an XML namespace handle for URL, which can then be used when specifying element names as options. Multiple names‐ paces can be registered by specifying this option multiple times. -n, --normalize Normalize space in the specified elements in addition to trim‐ ming whitespace. --version Show version information. The source XML file(s) containing the elements to trim. In addition, the following options allow configuration of the XML pars‐ er: --dtdload Load the external DTD. --huge Remove any internal arbitrary parser limits. --net Allow network access to load external DTD and entities. --noent Resolve entities. --xinclude Do XInclude processing. --xml-catalog Use an XML catalog when resolving entities. Multiple catalogs may be loaded by specifying this option multiple times. EXAMPLES Without namespace
Hello world.
$ xml-trim -e para example.xml
Hello world.
With namespace Hello world. $ xml-trim -N d=http://docbook.org/ns/docbook -e d:para example.xml Hello world. Normalizing space
This is a long paragraph with both extra whitespace before and after the text, and line breaks entered by the author to wrap the text on a certain column.
$ xml-trim -n -e para example.xml
This is a long paragraph with both extra whitespace before and after the text, and line breaks entered by the author to wrap the text on a certain column.
AUTHORS khzae.net. 2020-07-07 xml-trim(1)