/ .. / / -> download
.\" Automatically generated by Pandoc 2.3.1
.\"
.TH "xml\-format" "1" "2020\-07\-07" "" "xml\-utils"
.hy
.SH NAME
.PP
xml\-format \- Format XML files
.SH SYNOPSIS
.IP
.nf
\f[C]
xml\-format\ [\-cfIOwh?]\ [\-i\ <str>]\ [\-o\ <path>]\ [<file>...]
\f[]
.fi
.SH DESCRIPTION
.PP
The \f[I]xml\-format\f[] utility pretty prints an XML document by
removing ignorable blank nodes and indenting the XML tree.
.PP
A text node is considered ignorable if:
.IP \[bu] 2
its parent does not set or inherit xml:space as "preserve"
.IP \[bu] 2
its contents are entirely whitespace
.IP \[bu] 2
all its sibling text nodes are also ignorable
.IP \[bu] 2
all its ancestors contained only ignorable text nodes
.SH OPTIONS
.TP
.B \-c, \-\-compact
Output in compact form without indenting.
.RS
.RE
.TP
.B \-f, \-\-overwrite
Overwrite input XML files.
.RS
.RE
.TP
.B \-h, \-?, \-\-help
Show usage message.
.RS
.RE
.TP
.B \-I, \-\-indent\-all
Indent nodes within non\-blank nodes.
Normally, all whitespace within non\-blank nodes and their descendants
is treated as significant.
.RS
.PP
If \-c (\-\-compact) is specified, then this option will allow blank
nodes within non\-blank nodes to be compacted.
.RE
.TP
.B \-i, \-\-indent <str>
Use <str> to indent each level of the XML tree.
The default is two spaces.
.RS
.RE
.TP
.B \-O, \-\-omit\-decl
Omit the XML declaration from the formatted XML output.
.RS
.RE
.TP
.B \-o, \-\-out <path>
Output formatted XML to <path> instead of stdout.
.RS
.RE
.TP
.B \-w, \-\-empty
Treat elements containing only whitespace as empty.
.RS
.RE
.TP
.B \-\-version
Show version information.
.RS
.RE
.TP
.B <file>...
XML file(s) to format.
If none are specified, the utility will read from stdin.
.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
.PP
Raw XML:
.IP
.nf
\f[C]
$\ cat\ test.xml
<section>\ \ \ \ \ <title>Example</title>

<para><emphasis>A</emphasis>\ <emphasis>B</emphasis>\ C</para>

<empty>\ \ \ \ </empty>

<p><b>A</b>\ <b>B</b>\ <b>C</b></p>
<p\ xml:space="preserve"><b>A</b>\ <b>B</b>\ <b>C</b></p>

<para>
\ \ \ \ See\ the\ following\ list:
\ \ \ \ <randomList>
\ \ \ \ \ \ <listItem><para>A</para></listItem>
\ \ \ \ \ \ <listItem><para>B</para></listItem>
\ \ \ \ \ \ <listItem><para>C</para></listItem>
\ \ \ \ </randomList>
</para>

</section>
\ \ \ \ \ \ \ \ \ \ 
\f[]
.fi
.PP
Basic formatting:
.IP
.nf
\f[C]
$\ xml\-format\ test.xml
<section>
\ \ <title>Example</title>
\ \ <para><emphasis>A</emphasis>\ <emphasis>B</emphasis>\ C</para>
\ \ <empty>\ \ \ \ </empty>
\ \ <p>
\ \ \ \ <b>A</b>
\ \ \ \ <b>B</b>
\ \ \ \ <b>C</b>
\ \ </p>
\ \ <p\ xml:space="preserve"><b>A</b>\ <b>B</b>\ <b>C</b></p>
\ \ <para>
\ \ \ \ See\ the\ following\ list:
\ \ \ \ <randomList>
\ \ \ \ \ \ <listItem><para>A</para></listItem>
\ \ \ \ \ \ <listItem><para>B</para></listItem>
\ \ \ \ \ \ <listItem><para>C</para></listItem>
\ \ \ \ </randomList>
\ \ </para>
</section>
\f[]
.fi
.PP
Using the \-I (\-\-indent\-all) option:
.IP
.nf
\f[C]
$\ cat\ test1.xml
<para>
\ \ See\ the\ following\ list:
\ \ <randomList>
\ \ \ \ <listItem><para>A</para></listItem>
\ \ \ \ <listItem><para>B</para></listItem>
\ \ \ \ <listItem><para>C</para></listitem>
\ \ </randomList>
</para>

$\ xml\-format\ \-I\ test1.xml
<para>
\ \ See\ the\ following\ list:
\ \ <randomList>
\ \ \ \ <listItem>
\ \ \ \ \ \ <para>A</para>
\ \ \ \ </listItem>
\ \ \ \ <listItem>
\ \ \ \ \ \ <para>B</para>
\ \ \ \ </listItem>
\ \ \ \ <listItem>
\ \ \ \ \ \ <para>C</para>
\ \ \ \ </listItem>
\ \ </randomList>
</para>
\f[]
.fi
.PP
Using the \-c (\-\-compact) option:
.IP
.nf
\f[C]
$\ xml\-format\ test.xml
<section><title>Example</title><para><emphasis>A</emphasis>\ <emphasis
>B</emphasis>\ C</para><empty>\ \ \ \ </empty><p\ xml:space="preserve"><b>A
</b>\ <b>B</b>\ <b>C</b></p><para>
\ \ \ \ See\ the\ following\ list:
\ \ \ \ <randomList>
\ \ \ \ \ \ <listItem><para>A</para></listItem>
\ \ \ \ \ \ <listItem><para>B</para></listItem>
\ \ \ \ \ \ <listItem><para>C</para></listItem>
\ \ \ \ </randomList>
</para></section>
\f[]
.fi
.PP
Using the \-c (\-\-compact) and \-I (\-\-indent\-all) options together:
.IP
.nf
\f[C]
$\ xml\-format\ \-cI\ test.xml
<section><title>Example</title><para><emphasis>A</emphasis>\ <emphasis
>B</emphasis>\ C</para><empty>\ \ \ \ </empty><p\ xml:space="preserve"><b>A
</b>\ <b>B</b>\ <b>C</b></p><para>
\ \ \ \ See\ the\ following\ list:
\ \ \ \ <randomList><listItem><para>A</para></listItem><listItem><para>B<
/para></listItem><listItem><para>C</para></listItem></randomList>
</para></section>
\f[]
.fi
.SH AUTHORS
khzae.net.


/ gopher://khzae.net/0/s1000d/xml/xml-utils/src/utils/xml-format/doc/xml-format.1
Styles: Light Dark Classic