1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>xmllint</title><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="refentry"><a name="idm1"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>xmllint — command line <acronym class="acronym">XML</acronym> tool</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p><code class="command">xmllint</code> [ <code class="option">--version</code> | <code class="option">--debug</code> | <code class="option">--shell</code> | <code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code> | <code class="option">--debugent</code> | <code class="option">--copy</code> | <code class="option">--recover</code> | <code class="option">--noent</code> | <code class="option">--noout</code> | <code class="option">--nonet</code> | <code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code> | <code class="option">--load-trace</code> | <code class="option">--htmlout</code> | <code class="option">--nowrap</code> | <code class="option">--valid</code> | <code class="option">--postvalid</code> | <code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code> | <code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code> | <code class="option">--timing</code> | <code class="option">--output <em class="replaceable"><code>FILE</code></em></code> | <code class="option">--repeat</code> | <code class="option">--insert</code> | <code class="option">--compress</code> | <code class="option">--html</code> | <code class="option">--xmlout</code> | <code class="option">--push</code> | <code class="option">--memory</code> | <code class="option">--maxmem <em class="replaceable"><code>NBBYTES</code></em></code> | <code class="option">--nowarning</code> | <code class="option">--noblanks</code> | <code class="option">--nocdata</code> | <code class="option">--format</code> | <code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code> | <code class="option">--dropdtd</code> | <code class="option">--nsclean</code> | <code class="option">--testIO</code> | <code class="option">--catalogs</code> | <code class="option">--nocatalogs</code> | <code class="option">--auto</code> | <code class="option">--xinclude</code> | <code class="option">--noxincludenode</code> | <code class="option">--loaddtd</code> | <code class="option">--dtdattr</code> | <code class="option">--stream</code> | <code class="option">--walker</code> | <code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code> | <code class="option">--chkregister</code> | <code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code> | <code class="option">--c14n</code> ] { <em class="replaceable"><code>XML-FILE(S)</code></em>... | - }</p></div><div class="cmdsynopsis"><p><code class="command">xmllint</code> <code class="option">--help</code> </p></div></div><div class="refsect1"><a name="description"></a><h2>DESCRIPTION</h2><p>
|
---|
2 | The <span class="command"><strong>xmllint</strong></span> program parses one or more <acronym class="acronym">XML</acronym> files,
|
---|
3 | specified on the command line as <em class="replaceable"><code>XML-FILE</code></em>
|
---|
4 | (or the standard input if the filename provided
|
---|
5 | is <span class="bold"><strong>-</strong></span> ). It prints various types of
|
---|
6 | output, depending upon the options selected. It is useful for detecting
|
---|
7 | errors both in <acronym class="acronym">XML</acronym> code and in
|
---|
8 | the <acronym class="acronym">XML</acronym> parser itself.
|
---|
9 | </p><p><span class="command"><strong>xmllint</strong></span> is included in <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>.</p></div><div class="refsect1"><a name="options"></a><h2>OPTIONS</h2><p>
|
---|
10 | <span class="command"><strong>xmllint</strong></span> accepts the following options (in alphabetical order):
|
---|
11 | </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">--auto</code></span></dt><dd><p>Generate a small document for testing purposes.</p></dd><dt><span class="term"><code class="option">--catalogs</code></span></dt><dd><p>
|
---|
12 | Use the <acronym class="acronym">SGML</acronym> catalog(s) from <code class="envar">SGML_CATALOG_FILES</code>.
|
---|
13 | Otherwise <acronym class="acronym">XML</acronym> catalogs starting
|
---|
14 | from <code class="filename">/etc/xml/catalog</code> are used by default.
|
---|
15 | </p></dd><dt><span class="term"><code class="option">--chkregister</code></span></dt><dd><p>
|
---|
16 | Turn on node registration. Useful for developers testing <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> node tracking code.
|
---|
17 | </p></dd><dt><span class="term"><code class="option">--compress</code></span></dt><dd><p>
|
---|
18 | Turn on <span class="citerefentry"><span class="refentrytitle">gzip</span>(1)</span> compression of output.
|
---|
19 | </p></dd><dt><span class="term"><code class="option">--copy</code></span></dt><dd><p>Test the internal copy implementation.</p></dd><dt><span class="term"><code class="option">--c14n</code></span></dt><dd><p>
|
---|
20 | Use the W3C <acronym class="acronym">XML</acronym> Canonicalisation (<acronym class="acronym">C14N</acronym>) to
|
---|
21 | serialize the result of parsing to <code class="filename">stdout</code>.
|
---|
22 | It keeps comments in the result.
|
---|
23 | </p></dd><dt><span class="term"><code class="option">--dtdvalid <em class="replaceable"><code>URL</code></em></code></span></dt><dd><p>
|
---|
24 | Use the <acronym class="acronym">DTD</acronym> specified by
|
---|
25 | an <em class="replaceable"><code>URL</code></em> for validation.
|
---|
26 | </p></dd><dt><span class="term"><code class="option">--dtdvalidfpi <em class="replaceable"><code>FPI</code></em></code></span></dt><dd><p>
|
---|
27 | Use the <acronym class="acronym">DTD</acronym> specified by a Formal Public
|
---|
28 | Identifier <em class="replaceable"><code>FPI</code></em> for validation, note that this
|
---|
29 | will require a catalog exporting that Formal Public Identifier to work.
|
---|
30 | </p></dd><dt><span class="term"><code class="option">--debug</code></span></dt><dd><p>
|
---|
31 | Parse a file and output an annotated tree of the
|
---|
32 | in-memory version of the document.
|
---|
33 | </p></dd><dt><span class="term"><code class="option">--debugent</code></span></dt><dd><p>Debug the entities defined in the document.</p></dd><dt><span class="term"><code class="option">--dropdtd</code></span></dt><dd><p>Remove <acronym class="acronym">DTD</acronym> from output.</p></dd><dt><span class="term"><code class="option">--dtdattr</code></span></dt><dd><p>
|
---|
34 | Fetch external <acronym class="acronym">DTD</acronym> and populate the tree with
|
---|
35 | inherited attributes.
|
---|
36 | </p></dd><dt><span class="term"><code class="option">--encode <em class="replaceable"><code>ENCODING</code></em></code></span></dt><dd><p>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</p></dd><dt><span class="term"><code class="option">--format</code></span></dt><dd><p>
|
---|
37 | Reformat and reindent the output. The <code class="envar">XMLLINT_INDENT</code>
|
---|
38 | environment variable controls the indentation. The default value is two
|
---|
39 | spaces " ").
|
---|
40 | </p></dd><dt><span class="term"><code class="option">--help</code></span></dt><dd><p>Print out a short usage summary for <span class="command"><strong>xmllint</strong></span>.</p></dd><dt><span class="term"><code class="option">--html</code></span></dt><dd><p>Use the <acronym class="acronym">HTML</acronym> parser.</p></dd><dt><span class="term"><code class="option">--htmlout</code></span></dt><dd><p>
|
---|
41 | Output results as an <acronym class="acronym">HTML</acronym> file. This
|
---|
42 | causes <span class="command"><strong>xmllint</strong></span> to output the necessary <acronym class="acronym">HTML</acronym>
|
---|
43 | tags surrounding the result tree output so the results can be
|
---|
44 | displayed/viewed in a browser.
|
---|
45 | </p></dd><dt><span class="term"><code class="option">--insert</code></span></dt><dd><p>Test for valid insertions.</p></dd><dt><span class="term"><code class="option">--loaddtd</code></span></dt><dd><p>Fetch an external <acronym class="acronym">DTD</acronym>.</p></dd><dt><span class="term"><code class="option">--load-trace</code></span></dt><dd><p>
|
---|
46 | Display all the documents loaded during the processing
|
---|
47 | to <code class="filename">stderr</code>.
|
---|
48 | </p></dd><dt><span class="term"><code class="option">--maxmem <em class="replaceable"><code>NNBYTES</code></em></code></span></dt><dd><p>
|
---|
49 | Test the parser memory support. <em class="replaceable"><code>NNBYTES</code></em>
|
---|
50 | is the maximum number of bytes the library is allowed to allocate.
|
---|
51 | This can also be used to make sure batch processing
|
---|
52 | of <acronym class="acronym">XML</acronym> files will not exhaust the virtual memory
|
---|
53 | of the server running them.
|
---|
54 | </p></dd><dt><span class="term"><code class="option">--memory</code></span></dt><dd><p>Parse from memory.</p></dd><dt><span class="term"><code class="option">--noblanks</code></span></dt><dd><p>Drop ignorable blank spaces.</p></dd><dt><span class="term"><code class="option">--nocatalogs</code></span></dt><dd><p>Do not use any catalogs.</p></dd><dt><span class="term"><code class="option">--nocdata</code></span></dt><dd><p>Substitute CDATA section by equivalent text nodes.</p></dd><dt><span class="term"><code class="option">--noent</code></span></dt><dd><p>
|
---|
55 | Substitute entity values for entity references. By default, <span class="command"><strong>xmllint</strong></span>
|
---|
56 | leaves entity references in place.
|
---|
57 | </p></dd><dt><span class="term"><code class="option">--nonet</code></span></dt><dd><p>
|
---|
58 | Do not use the Internet to fetch <acronym class="acronym">DTD</acronym>s or entities.
|
---|
59 | </p></dd><dt><span class="term"><code class="option">--noout</code></span></dt><dd><p>
|
---|
60 | Suppress output. By default, <span class="command"><strong>xmllint</strong></span> outputs the result tree.
|
---|
61 | </p></dd><dt><span class="term"><code class="option">--nowarning</code></span></dt><dd><p>Do not emit warnings from the parser and/or validator.</p></dd><dt><span class="term"><code class="option">--nowrap</code></span></dt><dd><p>Do not output <acronym class="acronym">HTML</acronym> doc wrapper.</p></dd><dt><span class="term"><code class="option">--noxincludenode</code></span></dt><dd><p>
|
---|
62 | Do XInclude processing but do not generate XInclude start and end nodes.
|
---|
63 | </p></dd><dt><span class="term"><code class="option">--nsclean</code></span></dt><dd><p>Remove redundant namespace declarations.</p></dd><dt><span class="term"><code class="option">--output <em class="replaceable"><code>FILE</code></em></code></span></dt><dd><p>
|
---|
64 | Define a file path where <span class="command"><strong>xmllint</strong></span> will save the result of parsing.
|
---|
65 | Usually the programs build a tree and save it
|
---|
66 | on <code class="filename">stdout</code>, with this option
|
---|
67 | the result <acronym class="acronym">XML</acronym> instance will be saved onto a file.
|
---|
68 | </p></dd><dt><span class="term"><code class="option">--path "<em class="replaceable"><code>PATH(S)</code></em>"</code></span></dt><dd><p>
|
---|
69 | Use the (space- or colon-separated) list of filesystem paths specified
|
---|
70 | by <em class="replaceable"><code>PATHS</code></em> to load <acronym class="acronym">DTD</acronym>s or
|
---|
71 | entities. Enclose space-separated lists by quotation marks.
|
---|
72 | </p></dd><dt><span class="term"><code class="option">--pattern <em class="replaceable"><code>PATTERNVALUE</code></em></code></span></dt><dd><p>
|
---|
73 | Used to exercise the pattern recognition engine, which can be used
|
---|
74 | with the reader interface to the parser. It allows to select some
|
---|
75 | nodes in the document based on an XPath (subset) expression. Used
|
---|
76 | for debugging.
|
---|
77 | </p></dd><dt><span class="term"><code class="option">--postvalid</code></span></dt><dd><p>Validate after parsing has completed.</p></dd><dt><span class="term"><code class="option">--push</code></span></dt><dd><p>Use the push mode of the parser.</p></dd><dt><span class="term"><code class="option">--recover</code></span></dt><dd><p>Output any parsable portions of an invalid document.</p></dd><dt><span class="term"><code class="option">--relaxng <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
|
---|
78 | Use RelaxNG file named <em class="replaceable"><code>SCHEMA</code></em>
|
---|
79 | for validation.
|
---|
80 | </p></dd><dt><span class="term"><code class="option">--repeat</code></span></dt><dd><p>Repeat 100 times, for timing or profiling.</p></dd><dt><span class="term"><code class="option">--schema <em class="replaceable"><code>SCHEMA</code></em></code></span></dt><dd><p>
|
---|
81 | Use a W3C <acronym class="acronym">XML</acronym> Schema file
|
---|
82 | named <em class="replaceable"><code>SCHEMA</code></em> for validation.
|
---|
83 | </p></dd><dt><span class="term"><code class="option">--shell</code></span></dt><dd><p>
|
---|
84 | Run a navigating shell. Details on available commands in shell mode
|
---|
85 | are below (see <a class="xref" href="#shell" title="SHELL COMMANDS">the section called “SHELL COMMANDS”</a>).
|
---|
86 | </p></dd><dt><span class="term"><code class="option">--xpath "<em class="replaceable"><code>XPath_expression</code></em>"</code></span></dt><dd><p>
|
---|
87 | Run an XPath expression given as argument and print the
|
---|
88 | result. In case of a nodeset result, each node in the
|
---|
89 | node set is serialized in full in the output. In case
|
---|
90 | of an empty node set the "XPath set is empty" result
|
---|
91 | will be shown and an error exit code will be returned.
|
---|
92 | </p></dd><dt><span class="term"><code class="option">--stream</code></span></dt><dd><p>
|
---|
93 | Use streaming <acronym class="acronym">API</acronym> - useful when used in combination
|
---|
94 | with <code class="option">--relaxng</code> or <code class="option">--valid</code> options
|
---|
95 | for validation of files that are too large to be held in memory.
|
---|
96 | </p></dd><dt><span class="term"><code class="option">--testIO</code></span></dt><dd><p>Test user input/output support.</p></dd><dt><span class="term"><code class="option">--timing</code></span></dt><dd><p>
|
---|
97 | Output information about the time it takes <span class="command"><strong>xmllint</strong></span> to perform the
|
---|
98 | various steps.
|
---|
99 | </p></dd><dt><span class="term"><code class="option">--valid</code></span></dt><dd><p>
|
---|
100 | Determine if the document is a valid instance of the included
|
---|
101 | Document Type Definition (<acronym class="acronym">DTD</acronym>).
|
---|
102 | A <acronym class="acronym">DTD</acronym> to be validated against also can be
|
---|
103 | specified at the command line using the <code class="option">--dtdvalid</code>
|
---|
104 | option. By default, <span class="command"><strong>xmllint</strong></span> also checks to determine if the
|
---|
105 | document is well-formed.
|
---|
106 | </p></dd><dt><span class="term"><code class="option">--version</code></span></dt><dd><p>
|
---|
107 | Display the version of <span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> used.
|
---|
108 | </p></dd><dt><span class="term"><code class="option">--walker</code></span></dt><dd><p>
|
---|
109 | Test the walker module, which is a reader interface but for a
|
---|
110 | document tree, instead of using the reader <acronym class="acronym">API</acronym> on
|
---|
111 | an unparsed document it works on an existing in-memory tree. Used for
|
---|
112 | debugging.
|
---|
113 | </p></dd><dt><span class="term"><code class="option">--xinclude</code></span></dt><dd><p>Do XInclude processing.</p></dd><dt><span class="term"><code class="option">--xmlout</code></span></dt><dd><p>
|
---|
114 | Used in conjunction with <code class="option">--html</code>. Usually
|
---|
115 | when <acronym class="acronym">HTML</acronym> is parsed the document is saved with
|
---|
116 | the <acronym class="acronym">HTML</acronym> serializer. But with this option the
|
---|
117 | resulting document is saved with the <acronym class="acronym">XML</acronym>
|
---|
118 | serializer. This is primarily used to
|
---|
119 | generate <acronym class="acronym">XHTML</acronym> from <acronym class="acronym">HTML</acronym> input.
|
---|
120 | </p></dd></dl></div></div><div class="refsect1"><a name="shell"></a><h2>SHELL COMMANDS</h2><p>
|
---|
121 | <span class="command"><strong>xmllint</strong></span> offers an interactive shell mode invoked with
|
---|
122 | the <code class="option">--shell</code> command. Available commands in shell mode
|
---|
123 | include (in alphabetical order):
|
---|
124 | </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="command"><strong>base</strong></span></span></dt><dd><p>Display <acronym class="acronym">XML</acronym> base of the node.</p></dd><dt><span class="term"><span class="command"><strong>bye</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>cat <em class="replaceable"><code>NODE</code></em></strong></span></span></dt><dd><p>Display the given node or the current one.</p></dd><dt><span class="term"><span class="command"><strong>cd <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
|
---|
125 | Change the current node to the given path (if unique) or root if no
|
---|
126 | argument is given.
|
---|
127 | </p></dd><dt><span class="term"><span class="command"><strong>dir <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
|
---|
128 | Dumps information about the node (namespace, attributes, content).
|
---|
129 | </p></dd><dt><span class="term"><span class="command"><strong>du <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>
|
---|
130 | Show the structure of the subtree under the given path or the current node.
|
---|
131 | </p></dd><dt><span class="term"><span class="command"><strong>exit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>help</strong></span></span></dt><dd><p>Show this help.</p></dd><dt><span class="term"><span class="command"><strong>free</strong></span></span></dt><dd><p>Display memory usage.</p></dd><dt><span class="term"><span class="command"><strong>load <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Load a new document with the given filename.</p></dd><dt><span class="term"><span class="command"><strong>ls <em class="replaceable"><code>PATH</code></em></strong></span></span></dt><dd><p>List contents of the given path or the current directory.</p></dd><dt><span class="term"><span class="command"><strong>pwd</strong></span></span></dt><dd><p>Display the path to the current node.</p></dd><dt><span class="term"><span class="command"><strong>quit</strong></span></span></dt><dd><p>Leave the shell.</p></dd><dt><span class="term"><span class="command"><strong>save <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>
|
---|
132 | Save the current document to the given filename or to the original name.
|
---|
133 | </p></dd><dt><span class="term"><code class="option">validate</code></span></dt><dd><p>Check the document for errors.</p></dd><dt><span class="term"><span class="command"><strong>write <em class="replaceable"><code>FILENAME</code></em></strong></span></span></dt><dd><p>Write the current node to the given filename.</p></dd></dl></div></div><div class="refsect1"><a name="environment"></a><h2>ENVIRONMENT</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">SGML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">SGML</acronym> catalog behavior can be changed by redirecting
|
---|
134 | queries to the user's own set of catalogs. This can be done by setting
|
---|
135 | the <code class="envar">SGML_CATALOG_FILES</code> environment variable to a list
|
---|
136 | of catalogs. An empty one should deactivate loading the
|
---|
137 | default <code class="filename">/etc/sgml/catalog</code> catalog.
|
---|
138 | </p></dd><dt><span class="term"><code class="envar">XML_CATALOG_FILES</code></span></dt><dd><p><acronym class="acronym">XML</acronym> catalog behavior can be changed by redirecting
|
---|
139 | queries to the user's own set of catalogs. This can be done by setting
|
---|
140 | the <code class="envar">XML_CATALOG_FILES</code> environment variable to a space-separated
|
---|
141 | list of catalogs. Use percent-encoding to escape spaces or other characters.
|
---|
142 | An empty variable should deactivate loading the default <code class="filename">/etc/xml/catalog</code> catalog.
|
---|
143 | </p></dd><dt><span class="term"><code class="envar">XML_DEBUG_CATALOG</code></span></dt><dd><p>Setting the environment variable <code class="envar">XML_DEBUG_CATALOG</code>
|
---|
144 | to <em class="parameter"><code>non-zero</code></em> using the <span class="command"><strong>export</strong></span>
|
---|
145 | command outputs debugging information related to catalog operations.
|
---|
146 | </p></dd><dt><span class="term"><code class="envar">XMLLINT_INDENT</code></span></dt><dd><p>Setting the environment variable <code class="envar">XMLLINT_INDENT</code>
|
---|
147 | controls the indentation. The default value is two spaces " ".
|
---|
148 | </p></dd></dl></div></div><div class="refsect1"><a name="diagnostics"></a><h2>DIAGNOSTICS</h2><p>
|
---|
149 | <span class="command"><strong>xmllint</strong></span> return codes provide information that can be used when
|
---|
150 | calling it from scripts.
|
---|
151 | </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><span class="errorcode">0</span></span></dt><dd><p>No error</p></dd><dt><span class="term"><span class="errorcode">1</span></span></dt><dd><p>Unclassified</p></dd><dt><span class="term"><span class="errorcode">2</span></span></dt><dd><p>Error in <acronym class="acronym">DTD</acronym></p></dd><dt><span class="term"><span class="errorcode">3</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">4</span></span></dt><dd><p>Validation error</p></dd><dt><span class="term"><span class="errorcode">5</span></span></dt><dd><p>Error in schema compilation</p></dd><dt><span class="term"><span class="errorcode">6</span></span></dt><dd><p>Error writing output</p></dd><dt><span class="term"><span class="errorcode">7</span></span></dt><dd><p>
|
---|
152 | Error in pattern (generated when <code class="option">--pattern</code> option is used)
|
---|
153 | </p></dd><dt><span class="term"><span class="errorcode">8</span></span></dt><dd><p>
|
---|
154 | Error in Reader registration (generated
|
---|
155 | when <code class="option">--chkregister</code> option is used)
|
---|
156 | </p></dd><dt><span class="term"><span class="errorcode">9</span></span></dt><dd><p>Out of memory error</p></dd><dt><span class="term"><span class="errorcode">10</span></span></dt><dd><p>XPath evaluation error</p></dd></dl></div></div><div class="refsect1"><a name="seealso"></a><h2>SEE ALSO</h2><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span>
|
---|
157 | </p><p>
|
---|
158 | More information can be found at
|
---|
159 | </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><span class="citerefentry"><span class="refentrytitle">libxml</span>(3)</span> web page <a class="ulink" href="https://gitlab.gnome.org/GNOME/libxml2" target="_top">https://gitlab.gnome.org/GNOME/libxml2</a>
|
---|
160 | </p></li></ul></div><p>
|
---|
161 | </p></div></div></body></html>
|
---|