..
/
download
.\" Automatically generated by Pandoc 2.3.1
.\"
.TH "xml\-trim" "1" "2020\-07\-07" "" "xml\-utils"
.hy
.SH NAME
.PP
xml\-trim \- Trim whitespace in XML elements
.SH SYNOPSIS
.IP
.nf
\f[C]
xml\-trim\ [\-e\ <elem>\ ...]\ [\-N\ <ns=URL>\ ...]\ [\-fnh?]\ <src>...
\f[]
.fi
.SH DESCRIPTION
.PP
The \f[I]xml\-trim\f[] utility trims whitespace around the text contents
of specified elements.
.PP
Whitespace is trimmed according to the following rules:
.IP "1." 3
Whitespace characters at the beginning of the first text node child of
the specified elements are removed.
.IP "2." 3
Whitespace characters at the end of the last text node child of the
specified elements are removed.
.IP "3." 3
If the \-n option is given, sequences of whitespace characters in all
text node children of the specified elements are converted to a single
space.
.SH OPTIONS
.TP
.B \-e, \-\-element <elem>
Elements to trim space on.
May include a namespace prefix if the namespace was registered with \-N.
<elem> 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.
.RS
.RE
.TP
.B \-f, \-\-overwrite
Overwrite input XML files.
.RS
.RE
.TP
.B \-h, \-?, \-\-help
Show usage message.
.RS
.RE
.TP
.B \-N, \-\-namespace <ns=URL>
Registers an XML namespace handle for URL, which can then be used when
specifying element names as options.
Multiple namespaces can be registered by specifying this option multiple
times.
.RS
.RE
.TP
.B \-n, \-\-normalize
Normalize space in the specified elements in addition to trimming
whitespace.
.RS
.RE
.TP
.B \-\-version
Show version information.
.RS
.RE
.TP
.B <src>
The source XML file(s) containing the elements to trim.
.RS
.RE
.PP
In addition, the following options allow configuration of the XML
parser:
.TP
.B \-\-dtdload
Load the external DTD.
.RS
.RE
.TP
.B \-\-huge
Remove any internal arbitrary parser limits.
.RS
.RE
.TP
.B \-\-net
Allow network access to load external DTD and entities.
.RS
.RE
.TP
.B \-\-noent
Resolve entities.
.RS
.RE
.TP
.B \-\-xinclude
Do XInclude processing.
.RS
.RE
.TP
.B \-\-xml\-catalog <file>
Use an XML catalog when resolving entities.
Multiple catalogs may be loaded by specifying this option multiple
times.
.RS
.RE
.SH EXAMPLES
.SS Without namespace
.IP
.nf
\f[C]
<section>
\ \ <para>
\ \ \ \ Hello\ world.
\ \ </para>
</section>
\f[]
.fi
.IP
.nf
\f[C]
$\ xml\-trim\ \-e\ para\ example.xml
\f[]
.fi
.IP
.nf
\f[C]
<section>
\ \ <para>Hello\ world.</para>
</section>
\f[]
.fi
.SS With namespace
.IP
.nf
\f[C]
<d:section>
\ \ <d:para>
\ \ \ \ Hello\ world.
\ \ </d:para>
</d:section>
\f[]
.fi
.IP
.nf
\f[C]
$\ xml\-trim\ \-N\ d=http://docbook.org/ns/docbook\ \-e\ d:para\ example.xml
\f[]
.fi
.IP
.nf
\f[C]
<d:section>
\ \ <d:para>Hello\ world.</d:para>
</d:section>
\f[]
.fi
.SS Normalizing space
.IP
.nf
\f[C]
<section>
\ \ <para>
\ \ \ \ This\ is\ a\ <emphasis>long</emphasis>
\ \ \ \ 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.
\ \ </para>
</section>
\f[]
.fi
.IP
.nf
\f[C]
$\ xml\-trim\ \-n\ \-e\ para\ example.xml
\f[]
.fi
.IP
.nf
\f[C]
<section>
\ \ <para>This\ is\ a\ <emphasis>long</emphasis>\ 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.</para>
</section>
\f[]
.fi
.SH AUTHORS
khzae.net.
gopher://khzae.net/0/s1kd/xml/xml-utils/src/utils/xml-trim/doc/xml-trim.1