2 <?xml-stylesheet type="text/xsl"
3 href="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"?>
4 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
5 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
7 <!ENTITY xmllint "<command>xmllint</command>">
13 <title>xmllint Manual</title>
14 <productname>libxml2</productname>
21 <firstname>John</firstname>
22 <surname>Fleck</surname>
25 <email>jfleck@inkstain.net</email>
30 <firstname>Ziying</firstname>
31 <surname>Sherwin</surname>
34 <email>sherwin@nlm.nih.gov</email>
39 <firstname>Heiko</firstname>
40 <surname>Rupp</surname>
43 <email>hwr@pilhuhn.de</email>
48 <!-- date should be the date of the latest change or the release version -->
50 <!-- still a bit buggy output, will talk to docbook-xsl upstream to fix this -->
51 <!-- <releaseinfo>This is release 0.5 of the xmllint Manual.</releaseinfo> -->
52 <!-- <edition>0.5</edition> -->
56 <refentrytitle>xmllint</refentrytitle>
57 <manvolnum>1</manvolnum>
61 <refname>xmllint</refname>
62 <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
67 <command>xmllint</command>
69 <arg choice="plain"><option>--version</option></arg>
70 <arg choice="plain"><option>--debug</option></arg>
71 <arg choice="plain"><option>--shell</option></arg>
72 <arg choice="plain"><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></arg>
73 <arg choice="plain"><option>--debugent</option></arg>
74 <arg choice="plain"><option>--copy</option></arg>
75 <arg choice="plain"><option>--recover</option></arg>
76 <arg choice="plain"><option>--noent</option></arg>
77 <arg choice="plain"><option>--noout</option></arg>
78 <arg choice="plain"><option>--nonet</option></arg>
79 <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
80 <arg choice="plain"><option>--load-trace</option></arg>
81 <arg choice="plain"><option>--htmlout</option></arg>
82 <arg choice="plain"><option>--nowrap</option></arg>
83 <arg choice="plain"><option>--valid</option></arg>
84 <arg choice="plain"><option>--postvalid</option></arg>
85 <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
86 <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
87 <arg choice="plain"><option>--timing</option></arg>
88 <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
89 <arg choice="plain"><option>--repeat</option></arg>
90 <arg choice="plain"><option>--insert</option></arg>
91 <arg choice="plain"><option>--compress</option></arg>
92 <arg choice="plain"><option>--html</option></arg>
93 <arg choice="plain"><option>--xmlout</option></arg>
94 <arg choice="plain"><option>--push</option></arg>
95 <arg choice="plain"><option>--memory</option></arg>
96 <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
97 <arg choice="plain"><option>--nowarning</option></arg>
98 <arg choice="plain"><option>--noblanks</option></arg>
99 <arg choice="plain"><option>--nocdata</option></arg>
100 <arg choice="plain"><option>--format</option></arg>
101 <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
102 <arg choice="plain"><option>--dropdtd</option></arg>
103 <arg choice="plain"><option>--nsclean</option></arg>
104 <arg choice="plain"><option>--testIO</option></arg>
105 <arg choice="plain"><option>--catalogs</option></arg>
106 <arg choice="plain"><option>--nocatalogs</option></arg>
107 <arg choice="plain"><option>--auto</option></arg>
108 <arg choice="plain"><option>--xinclude</option></arg>
109 <arg choice="plain"><option>--noxincludenode</option></arg>
110 <arg choice="plain"><option>--loaddtd</option></arg>
111 <arg choice="plain"><option>--dtdattr</option></arg>
112 <arg choice="plain"><option>--stream</option></arg>
113 <arg choice="plain"><option>--walker</option></arg>
114 <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
115 <arg choice="plain"><option>--chkregister</option></arg>
116 <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
117 <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
118 <arg choice="plain"><option>--c14n</option></arg>
121 <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
122 <arg choice="plain" rep="norepeat">-</arg>
126 <command>xmllint</command>
127 <arg choice="plain"><option>--help</option></arg>
131 <refsect1 id="description">
132 <title>DESCRIPTION</title>
134 The &xmllint; program parses one or more <acronym>XML</acronym> files,
135 specified on the command line as <replaceable>XML-FILE</replaceable>
136 (or the standard input if the filename provided
137 is <emphasis role="bold">-</emphasis> ). It prints various types of
138 output, depending upon the options selected. It is useful for detecting
139 errors both in <acronym>XML</acronym> code and in
140 the <acronym>XML</acronym> parser itself.
142 <para>&xmllint; is included in <citerefentry>
143 <refentrytitle>libxml</refentrytitle>
144 <manvolnum>3</manvolnum>
145 </citerefentry>.</para>
148 <refsect1 id="options">
149 <title>OPTIONS</title>
151 &xmllint; accepts the following options (in alphabetical order):
157 <term><option>--auto</option></term>
159 <para>Generate a small document for testing purposes.</para>
164 <term><option>--catalogs</option></term>
167 Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
168 Otherwise <acronym>XML</acronym> catalogs starting
169 from <filename>/etc/xml/catalog</filename> are used by default.
175 <term><option>--chkregister</option></term>
178 Turn on node registration. Useful for developers testing <citerefentry>
179 <refentrytitle>libxml</refentrytitle>
180 <manvolnum>3</manvolnum>
181 </citerefentry> node tracking code.
187 <term><option>--compress</option></term>
190 Turn on <citerefentry>
191 <refentrytitle>gzip</refentrytitle>
192 <manvolnum>1</manvolnum>
193 </citerefentry> compression of output.
199 <term><option>--copy</option></term>
201 <para>Test the internal copy implementation.</para>
206 <term><option>--c14n</option></term>
209 Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
210 serialize the result of parsing to <filename class="devicefile">stdout</filename>.
211 It keeps comments in the result.
217 <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
220 Use the <acronym>DTD</acronym> specified by
221 an <replaceable>URL</replaceable> for validation.
227 <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
230 Use the <acronym>DTD</acronym> specified by a Formal Public
231 Identifier <replaceable>FPI</replaceable> for validation, note that this
232 will require a catalog exporting that Formal Public Identifier to work.
238 <term><option>--debug</option></term>
241 Parse a file and output an annotated tree of the
242 in-memory version of the document.
248 <term><option>--debugent</option></term>
250 <para>Debug the entities defined in the document.</para>
255 <term><option>--dropdtd</option></term>
257 <para>Remove <acronym>DTD</acronym> from output.</para>
262 <term><option>--dtdattr</option></term>
265 Fetch external <acronym>DTD</acronym> and populate the tree with
266 inherited attributes.
272 <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
274 <para>Output in the given encoding. Note that this works for full document not fragments or result from XPath queries.</para>
279 <term><option>--format</option></term>
282 Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
283 environment variable controls the indentation. The default value is two
284 spaces " ").
290 <term><option>--help</option></term>
292 <para>Print out a short usage summary for &xmllint;.</para>
297 <term><option>--html</option></term>
299 <para>Use the <acronym>HTML</acronym> parser.</para>
304 <term><option>--htmlout</option></term>
307 Output results as an <acronym>HTML</acronym> file. This
308 causes &xmllint; to output the necessary <acronym>HTML</acronym>
309 tags surrounding the result tree output so the results can be
310 displayed/viewed in a browser.
316 <term><option>--insert</option></term>
318 <para>Test for valid insertions.</para>
323 <term><option>--loaddtd</option></term>
325 <para>Fetch an external <acronym>DTD</acronym>.</para>
330 <term><option>--load-trace</option></term>
333 Display all the documents loaded during the processing
334 to <filename class="devicefile">stderr</filename>.
340 <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
343 Test the parser memory support. <replaceable>NNBYTES</replaceable>
344 is the maximum number of bytes the library is allowed to allocate.
345 This can also be used to make sure batch processing
346 of <acronym>XML</acronym> files will not exhaust the virtual memory
347 of the server running them.
353 <term><option>--memory</option></term>
355 <para>Parse from memory.</para>
360 <term><option>--noblanks</option></term>
362 <para>Drop ignorable blank spaces.</para>
367 <term><option>--nocatalogs</option></term>
369 <para>Do not use any catalogs.</para>
374 <term><option>--nocdata</option></term>
376 <para>Substitute CDATA section by equivalent text nodes.</para>
381 <term><option>--noent</option></term>
384 Substitute entity values for entity references. By default, &xmllint;
385 leaves entity references in place.
391 <term><option>--nonet</option></term>
394 Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
400 <term><option>--noout</option></term>
403 Suppress output. By default, &xmllint; outputs the result tree.
409 <term><option>--nowarning</option></term>
411 <para>Do not emit warnings from the parser and/or validator.</para>
416 <term><option>--nowrap</option></term>
418 <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
423 <term><option>--noxincludenode</option></term>
426 Do XInclude processing but do not generate XInclude start and end nodes.
432 <term><option>--nsclean</option></term>
434 <para>Remove redundant namespace declarations.</para>
439 <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
442 Define a file path where &xmllint; will save the result of parsing.
443 Usually the programs build a tree and save it
444 on <filename class="devicefile">stdout</filename>, with this option
445 the result <acronym>XML</acronym> instance will be saved onto a file.
451 <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
454 Use the (space- or colon-separated) list of filesystem paths specified
455 by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
456 entities. Enclose space-separated lists by quotation marks.
462 <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
465 Used to exercise the pattern recognition engine, which can be used
466 with the reader interface to the parser. It allows to select some
467 nodes in the document based on an XPath (subset) expression. Used
474 <term><option>--postvalid</option></term>
476 <para>Validate after parsing has completed.</para>
481 <term><option>--push</option></term>
483 <para>Use the push mode of the parser.</para>
488 <term><option>--recover</option></term>
490 <para>Output any parsable portions of an invalid document.</para>
495 <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
498 Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
505 <term><option>--repeat</option></term>
507 <para>Repeat 100 times, for timing or profiling.</para>
512 <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
515 Use a W3C <acronym>XML</acronym> Schema file
516 named <replaceable>SCHEMA</replaceable> for validation.
522 <term><option>--shell</option></term>
525 Run a navigating shell. Details on available commands in shell mode
526 are below (see <xref linkend="shell"/>).
532 <term><option>--xpath "<replaceable class="option">XPath_expression</replaceable>"</option></term>
535 Run an XPath expression given as argument and print the
536 result. In case of a nodeset result, each node in the
537 node set is serialized in full in the output. In case
538 of an empty node set the "XPath set is empty" result
539 will be shown and an error exit code will be returned.
545 <term><option>--stream</option></term>
548 Use streaming <acronym>API</acronym> - useful when used in combination
549 with <option>--relaxng</option> or <option>--valid</option> options
550 for validation of files that are too large to be held in memory.
556 <term><option>--testIO</option></term>
558 <para>Test user input/output support.</para>
563 <term><option>--timing</option></term>
566 Output information about the time it takes &xmllint; to perform the
573 <term><option>--valid</option></term>
576 Determine if the document is a valid instance of the included
577 Document Type Definition (<acronym>DTD</acronym>).
578 A <acronym>DTD</acronym> to be validated against also can be
579 specified at the command line using the <option>--dtdvalid</option>
580 option. By default, &xmllint; also checks to determine if the
581 document is well-formed.
587 <term><option>--version</option></term>
590 Display the version of <citerefentry>
591 <refentrytitle>libxml</refentrytitle>
592 <manvolnum>3</manvolnum>
593 </citerefentry> used.
599 <term><option>--walker</option></term>
602 Test the walker module, which is a reader interface but for a
603 document tree, instead of using the reader <acronym>API</acronym> on
604 an unparsed document it works on an existing in-memory tree. Used for
611 <term><option>--xinclude</option></term>
613 <para>Do XInclude processing.</para>
618 <term><option>--xmlout</option></term>
621 Used in conjunction with <option>--html</option>. Usually
622 when <acronym>HTML</acronym> is parsed the document is saved with
623 the <acronym>HTML</acronym> serializer. But with this option the
624 resulting document is saved with the <acronym>XML</acronym>
625 serializer. This is primarily used to
626 generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
634 <refsect1 id="shell">
635 <title>SHELL COMMANDS</title>
637 &xmllint; offers an interactive shell mode invoked with
638 the <option>--shell</option> command. Available commands in shell mode
639 include (in alphabetical order):
644 <term><command>base</command></term>
646 <para>Display <acronym>XML</acronym> base of the node.</para>
651 <term><command>bye</command></term>
653 <para>Leave the shell.</para>
658 <term><command>cat <replaceable>NODE</replaceable></command></term>
660 <para>Display the given node or the current one.</para>
665 <term><command>cd <replaceable>PATH</replaceable></command></term>
668 Change the current node to the given path (if unique) or root if no
675 <term><command>dir <replaceable>PATH</replaceable></command></term>
678 Dumps information about the node (namespace, attributes, content).
684 <term><command>du <replaceable>PATH</replaceable></command></term>
687 Show the structure of the subtree under the given path or the current node.
693 <term><command>exit</command></term>
695 <para>Leave the shell.</para>
700 <term><command>help</command></term>
702 <para>Show this help.</para>
707 <term><command>free</command></term>
709 <para>Display memory usage.</para>
714 <term><command>load <replaceable>FILENAME</replaceable></command></term>
716 <para>Load a new document with the given filename.</para>
721 <term><command>ls <replaceable>PATH</replaceable></command></term>
723 <para>List contents of the given path or the current directory.</para>
728 <term><command>pwd</command></term>
730 <para>Display the path to the current node.</para>
735 <term><command>quit</command></term>
737 <para>Leave the shell.</para>
742 <term><command>save <replaceable>FILENAME</replaceable></command></term>
745 Save the current document to the given filename or to the original name.
751 <term><option>validate</option></term>
753 <para>Check the document for errors.</para>
758 <term><command>write <replaceable>FILENAME</replaceable></command></term>
760 <para>Write the current node to the given filename.</para>
767 <refsect1 id="environment">
768 <title>ENVIRONMENT</title>
772 <term><envar>SGML_CATALOG_FILES</envar></term>
774 <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
775 queries to the user's own set of catalogs. This can be done by setting
776 the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
777 of catalogs. An empty one should deactivate loading the
778 default <filename>/etc/sgml/catalog</filename> catalog.
784 <term><envar>XML_CATALOG_FILES</envar></term>
786 <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
787 queries to the user's own set of catalogs. This can be done by setting
788 the <envar>XML_CATALOG_FILES</envar> environment variable to a list
789 of catalogs. An empty one should deactivate loading the
790 default <filename>/etc/xml/catalog</filename> catalog.
796 <term><envar>XML_DEBUG_CATALOG</envar></term>
798 <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
799 to <parameter>non-zero</parameter> using the <command>export</command>
800 command outputs debugging information related to catalog operations.
806 <term><envar>XMLLINT_INDENT</envar></term>
808 <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
809 controls the indentation. The default value is two spaces " ".
817 <refsect1 id="diagnostics">
818 <title>DIAGNOSTICS</title>
820 &xmllint; return codes provide information that can be used when
821 calling it from scripts.
823 <!-- better use segmentedlist element later,
824 which is currently only supported in snapshots -->
828 <term><errorcode>0</errorcode></term>
830 <para>No error</para>
835 <term><errorcode>1</errorcode></term>
837 <para>Unclassified</para>
842 <term><errorcode>2</errorcode></term>
844 <para>Error in <acronym>DTD</acronym></para>
849 <term><errorcode>3</errorcode></term>
851 <para>Validation error</para>
856 <term><errorcode>4</errorcode></term>
858 <para>Validation error</para>
863 <term><errorcode>5</errorcode></term>
865 <para>Error in schema compilation</para>
870 <term><errorcode>6</errorcode></term>
872 <para>Error writing output</para>
877 <term><errorcode>7</errorcode></term>
880 Error in pattern (generated when <option>--pattern</option> option is used)
886 <term><errorcode>8</errorcode></term>
889 Error in Reader registration (generated
890 when <option>--chkregister</option> option is used)
896 <term><errorcode>9</errorcode></term>
898 <para>Out of memory error</para>
905 <refsect1 id="seealso">
906 <title>SEE ALSO</title>
908 <refentrytitle>libxml</refentrytitle>
909 <manvolnum>3</manvolnum>
913 More information can be found at
917 <refentrytitle>libxml</refentrytitle>
918 <manvolnum>3</manvolnum>
919 </citerefentry> web page <ulink url="http://www.xmlsoft.org/"/>
923 <para>W3C <acronym>XSLT</acronym> page <ulink url="http://www.w3.org/TR/xslt"/>