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>--debugent</option></arg>
73 <arg choice="plain"><option>--copy</option></arg>
74 <arg choice="plain"><option>--recover</option></arg>
75 <arg choice="plain"><option>--noent</option></arg>
76 <arg choice="plain"><option>--noout</option></arg>
77 <arg choice="plain"><option>--nonet</option></arg>
78 <arg choice="plain"><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></arg>
79 <arg choice="plain"><option>--load-trace</option></arg>
80 <arg choice="plain"><option>--htmlout</option></arg>
81 <arg choice="plain"><option>--nowrap</option></arg>
82 <arg choice="plain"><option>--valid</option></arg>
83 <arg choice="plain"><option>--postvalid</option></arg>
84 <arg choice="plain"><option>--dtdvalid <replaceable class="option">URL</replaceable></option></arg>
85 <arg choice="plain"><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></arg>
86 <arg choice="plain"><option>--timing</option></arg>
87 <arg choice="plain"><option>--output <replaceable class="option">FILE</replaceable></option></arg>
88 <arg choice="plain"><option>--repeat</option></arg>
89 <arg choice="plain"><option>--insert</option></arg>
90 <arg choice="plain"><option>--compress</option></arg>
91 <arg choice="plain"><option>--html</option></arg>
92 <arg choice="plain"><option>--xmlout</option></arg>
93 <arg choice="plain"><option>--push</option></arg>
94 <arg choice="plain"><option>--memory</option></arg>
95 <arg choice="plain"><option>--maxmem <replaceable class="option">NBBYTES</replaceable></option></arg>
96 <arg choice="plain"><option>--nowarning</option></arg>
97 <arg choice="plain"><option>--noblanks</option></arg>
98 <arg choice="plain"><option>--nocdata</option></arg>
99 <arg choice="plain"><option>--format</option></arg>
100 <arg choice="plain"><option>--encode <replaceable class="option">ENCODING</replaceable></option></arg>
101 <arg choice="plain"><option>--dropdtd</option></arg>
102 <arg choice="plain"><option>--nsclean</option></arg>
103 <arg choice="plain"><option>--testIO</option></arg>
104 <arg choice="plain"><option>--catalogs</option></arg>
105 <arg choice="plain"><option>--nocatalogs</option></arg>
106 <arg choice="plain"><option>--auto</option></arg>
107 <arg choice="plain"><option>--xinclude</option></arg>
108 <arg choice="plain"><option>--noxincludenode</option></arg>
109 <arg choice="plain"><option>--loaddtd</option></arg>
110 <arg choice="plain"><option>--dtdattr</option></arg>
111 <arg choice="plain"><option>--stream</option></arg>
112 <arg choice="plain"><option>--walker</option></arg>
113 <arg choice="plain"><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></arg>
114 <arg choice="plain"><option>--chkregister</option></arg>
115 <arg choice="plain"><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></arg>
116 <arg choice="plain"><option>--schema <replaceable class="option">SCHEMA</replaceable></option></arg>
117 <arg choice="plain"><option>--c14n</option></arg>
120 <arg choice="plain" rep="repeat"><replaceable>XML-FILE(S)</replaceable></arg>
121 <arg choice="plain" rep="norepeat">-</arg>
125 <command>xmllint</command>
126 <arg choice="plain"><option>--help</option></arg>
130 <refsect1 id="description">
131 <title>DESCRIPTION</title>
133 The &xmllint; program parses one or more <acronym>XML</acronym> files,
134 specified on the command line as <replaceable>XML-FILE</replaceable>
135 (or the standard input if the filename provided
136 is <emphasis role="bold">-</emphasis> ). It prints various types of
137 output, depending upon the options selected. It is useful for detecting
138 errors both in <acronym>XML</acronym> code and in
139 the <acronym>XML</acronym> parser itself.
141 <para>&xmllint; is included in <citerefentry>
142 <refentrytitle>libxml</refentrytitle>
143 <manvolnum>3</manvolnum>
144 </citerefentry>.</para>
147 <refsect1 id="options">
148 <title>OPTIONS</title>
150 &xmllint; accepts the following options (in alphabetical order):
156 <term><option>--auto</option></term>
158 <para>Generate a small document for testing purposes.</para>
163 <term><option>--catalogs</option></term>
166 Use the <acronym>SGML</acronym> catalog(s) from <envar>SGML_CATALOG_FILES</envar>.
167 Otherwise <acronym>XML</acronym> catalogs starting
168 from <filename>/etc/xml/catalog</filename> are used by default.
174 <term><option>--chkregister</option></term>
177 Turn on node registration. Useful for developers testing <citerefentry>
178 <refentrytitle>libxml</refentrytitle>
179 <manvolnum>3</manvolnum>
180 </citerefentry> node tracking code.
186 <term><option>--compress</option></term>
189 Turn on <citerefentry>
190 <refentrytitle>gzip</refentrytitle>
191 <manvolnum>1</manvolnum>
192 </citerefentry> compression of output.
198 <term><option>--copy</option></term>
200 <para>Test the internal copy implementation.</para>
205 <term><option>--c14n</option></term>
208 Use the W3C <acronym>XML</acronym> Canonicalisation (<acronym>C14N</acronym>) to
209 serialize the result of parsing to <filename class="devicefile">stdout</filename>.
210 It keeps comments in the result.
216 <term><option>--dtdvalid <replaceable class="option">URL</replaceable></option></term>
219 Use the <acronym>DTD</acronym> specified by
220 an <replaceable>URL</replaceable> for validation.
226 <term><option>--dtdvalidfpi <replaceable class="option">FPI</replaceable></option></term>
229 Use the <acronym>DTD</acronym> specified by a Formal Public
230 Identifier <replaceable>FPI</replaceable> for validation, note that this
231 will require a catalog exporting that Formal Public Identifier to work.
237 <term><option>--debug</option></term>
240 Parse a file and output an annotated tree of the
241 in-memory version of the document.
247 <term><option>--debugent</option></term>
249 <para>Debug the entities defined in the document.</para>
254 <term><option>--dropdtd</option></term>
256 <para>Remove <acronym>DTD</acronym> from output.</para>
261 <term><option>--dtdattr</option></term>
264 Fetch external <acronym>DTD</acronym> and populate the tree with
265 inherited attributes.
271 <term><option>--encode <replaceable class="option">ENCODING</replaceable></option></term>
273 <para>Output in the given encoding.</para>
278 <term><option>--format</option></term>
281 Reformat and reindent the output. The <envar>XMLLINT_INDENT</envar>
282 environment variable controls the indentation. The default value is two
283 spaces " ").
289 <term><option>--help</option></term>
291 <para>Print out a short usage summary for &xmllint;.</para>
296 <term><option>--html</option></term>
298 <para>Use the <acronym>HTML</acronym> parser.</para>
303 <term><option>--htmlout</option></term>
306 Output results as an <acronym>HTML</acronym> file. This
307 causes &xmllint; to output the necessary <acronym>HTML</acronym>
308 tags surrounding the result tree output so the results can be
309 displayed/viewed in a browser.
315 <term><option>--insert</option></term>
317 <para>Test for valid insertions.</para>
322 <term><option>--loaddtd</option></term>
324 <para>Fetch an external <acronym>DTD</acronym>.</para>
329 <term><option>--load-trace</option></term>
332 Display all the documents loaded during the processing
333 to <filename class="devicefile">stderr</filename>.
339 <term><option>--maxmem <replaceable class="option">NNBYTES</replaceable></option></term>
342 Test the parser memory support. <replaceable>NNBYTES</replaceable>
343 is the maximum number of bytes the library is allowed to allocate.
344 This can also be used to make sure batch processing
345 of <acronym>XML</acronym> files will not exhaust the virtual memory
346 of the server running them.
352 <term><option>--memory</option></term>
354 <para>Parse from memory.</para>
359 <term><option>--noblanks</option></term>
361 <para>Drop ignorable blank spaces.</para>
366 <term><option>--nocatalogs</option></term>
368 <para>Do not use any catalogs.</para>
373 <term><option>--nocdata</option></term>
375 <para>Substitute CDATA section by equivalent text nodes.</para>
380 <term><option>--noent</option></term>
383 Substitute entity values for entity references. By default, &xmllint;
384 leaves entity references in place.
390 <term><option>--nonet</option></term>
393 Do not use the Internet to fetch <acronym>DTD</acronym>s or entities.
399 <term><option>--noout</option></term>
402 Suppress output. By default, &xmllint; outputs the result tree.
408 <term><option>--nowarning</option></term>
410 <para>Do not emit warnings from the parser and/or validator.</para>
415 <term><option>--nowrap</option></term>
417 <para>Do not output <acronym>HTML</acronym> doc wrapper.</para>
422 <term><option>--noxincludenode</option></term>
425 Do XInclude processing but do not generate XInclude start and end nodes.
431 <term><option>--nsclean</option></term>
433 <para>Remove redundant namespace declarations.</para>
438 <term><option>--output <replaceable class="option">FILE</replaceable></option></term>
441 Define a file path where &xmllint; will save the result of parsing.
442 Usually the programs build a tree and save it
443 on <filename class="devicefile">stdout</filename>, with this option
444 the result <acronym>XML</acronym> instance will be saved onto a file.
450 <term><option>--path "<replaceable class="option">PATH(S)</replaceable>"</option></term>
453 Use the (space- or colon-separated) list of filesystem paths specified
454 by <replaceable>PATHS</replaceable> to load <acronym>DTD</acronym>s or
455 entities. Enclose space-separated lists by quotation marks.
461 <term><option>--pattern <replaceable class="option">PATTERNVALUE</replaceable></option></term>
464 Used to exercise the pattern recognition engine, which can be used
465 with the reader interface to the parser. It allows to select some
466 nodes in the document based on an XPath (subset) expression. Used
473 <term><option>--postvalid</option></term>
475 <para>Validate after parsing has completed.</para>
480 <term><option>--push</option></term>
482 <para>Use the push mode of the parser.</para>
487 <term><option>--recover</option></term>
489 <para>Output any parsable portions of an invalid document.</para>
494 <term><option>--relaxng <replaceable class="option">SCHEMA</replaceable></option></term>
497 Use RelaxNG file named <replaceable class="option">SCHEMA</replaceable>
504 <term><option>--repeat</option></term>
506 <para>Repeat 100 times, for timing or profiling.</para>
511 <term><option>--schema <replaceable>SCHEMA</replaceable></option></term>
514 Use a W3C <acronym>XML</acronym> Schema file
515 named <replaceable>SCHEMA</replaceable> for validation.
521 <term><option>--shell</option></term>
524 Run a navigating shell. Details on available commands in shell mode
525 are below (see <xref linkend="shell"/>).
531 <term><option>--stream</option></term>
534 Use streaming <acronym>API</acronym> - useful when used in combination
535 with <option>--relaxng</option> or <option>--valid</option> options
536 for validation of files that are too large to be held in memory.
542 <term><option>--testIO</option></term>
544 <para>Test user input/output support.</para>
549 <term><option>--timing</option></term>
552 Output information about the time it takes &xmllint; to perform the
559 <term><option>--valid</option></term>
562 Determine if the document is a valid instance of the included
563 Document Type Definition (<acronym>DTD</acronym>).
564 A <acronym>DTD</acronym> to be validated against also can be
565 specified at the command line using the <option>--dtdvalid</option>
566 option. By default, &xmllint; also checks to determine if the
567 document is well-formed.
573 <term><option>--version</option></term>
576 Display the version of <citerefentry>
577 <refentrytitle>libxml</refentrytitle>
578 <manvolnum>3</manvolnum>
579 </citerefentry> used.
585 <term><option>--walker</option></term>
588 Test the walker module, which is a reader interface but for a
589 document tree, instead of using the reader <acronym>API</acronym> on
590 an unparsed document it works on an existing in-memory tree. Used for
597 <term><option>--xinclude</option></term>
599 <para>Do XInclude processing.</para>
604 <term><option>--xmlout</option></term>
607 Used in conjunction with <option>--html</option>. Usually
608 when <acronym>HTML</acronym> is parsed the document is saved with
609 the <acronym>HTML</acronym> serializer. But with this option the
610 resulting document is saved with the <acronym>XML</acronym>
611 serializer. This is primarily used to
612 generate <acronym>XHTML</acronym> from <acronym>HTML</acronym> input.
620 <refsect1 id="shell">
621 <title>SHELL COMMANDS</title>
623 &xmllint; offers an interactive shell mode invoked with
624 the <option>--shell</option> command. Available commands in shell mode
625 include (in alphabetical order):
630 <term><command>base</command></term>
632 <para>Display <acronym>XML</acronym> base of the node.</para>
637 <term><command>bye</command></term>
639 <para>Leave the shell.</para>
644 <term><command>cat <replaceable>NODE</replaceable></command></term>
646 <para>Display the given node or the current one.</para>
651 <term><command>cd <replaceable>PATH</replaceable></command></term>
654 Change the current node to the given path (if unique) or root if no
661 <term><command>dir <replaceable>PATH</replaceable></command></term>
664 Dumps information about the node (namespace, attributes, content).
670 <term><command>du <replaceable>PATH</replaceable></command></term>
673 Show the structure of the subtree under the given path or the current node.
679 <term><command>exit</command></term>
681 <para>Leave the shell.</para>
686 <term><command>help</command></term>
688 <para>Show this help.</para>
693 <term><command>free</command></term>
695 <para>Display memory usage.</para>
700 <term><command>load <replaceable>FILENAME</replaceable></command></term>
702 <para>Load a new document with the given filename.</para>
707 <term><command>ls <replaceable>PATH</replaceable></command></term>
709 <para>List contents of the given path or the current directory.</para>
714 <term><command>pwd</command></term>
716 <para>Display the path to the current node.</para>
721 <term><command>quit</command></term>
723 <para>Leave the shell.</para>
728 <term><command>save <replaceable>FILENAME</replaceable></command></term>
731 Save the current document to the given filename or to the original name.
737 <term><option>validate</option></term>
739 <para>Check the document for errors.</para>
744 <term><command>write <replaceable>FILENAME</replaceable></command></term>
746 <para>Write the current node to the given filename.</para>
753 <refsect1 id="environment">
754 <title>ENVIRONMENT</title>
758 <term><envar>SGML_CATALOG_FILES</envar></term>
760 <para><acronym>SGML</acronym> catalog behavior can be changed by redirecting
761 queries to the user's own set of catalogs. This can be done by setting
762 the <envar>SGML_CATALOG_FILES</envar> environment variable to a list
763 of catalogs. An empty one should deactivate loading the
764 default <filename>/etc/sgml/catalog</filename> catalog.
770 <term><envar>XML_CATALOG_FILES</envar></term>
772 <para><acronym>XML</acronym> catalog behavior can be changed by redirecting
773 queries to the user's own set of catalogs. This can be done by setting
774 the <envar>XML_CATALOG_FILES</envar> environment variable to a list
775 of catalogs. An empty one should deactivate loading the
776 default <filename>/etc/xml/catalog</filename> catalog.
782 <term><envar>XML_DEBUG_CATALOG</envar></term>
784 <para>Setting the environment variable <envar>XML_DEBUG_CATALOG</envar>
785 to <parameter>non-zero</parameter> using the <command>export</command>
786 command outputs debugging information related to catalog operations.
792 <term><envar>XMLLINT_INDENT</envar></term>
794 <para>Setting the environment variable <envar>XMLLINT_INDENT</envar>
795 controls the indentation. The default value is two spaces " ".
803 <refsect1 id="diagnostics">
804 <title>DIAGNOSTICS</title>
806 &xmllint; return codes provide information that can be used when
807 calling it from scripts.
809 <!-- better use segmentedlist element later,
810 which is currently only supported in snapshots -->
814 <term><errorcode>0</errorcode></term>
816 <para>No error</para>
821 <term><errorcode>1</errorcode></term>
823 <para>Unclassified</para>
828 <term><errorcode>2</errorcode></term>
830 <para>Error in <acronym>DTD</acronym></para>
835 <term><errorcode>3</errorcode></term>
837 <para>Validation error</para>
842 <term><errorcode>4</errorcode></term>
844 <para>Validation error</para>
849 <term><errorcode>5</errorcode></term>
851 <para>Error in schema compilation</para>
856 <term><errorcode>6</errorcode></term>
858 <para>Error writing output</para>
863 <term><errorcode>7</errorcode></term>
866 Error in pattern (generated when <option>--pattern</option> option is used)
872 <term><errorcode>8</errorcode></term>
875 Error in Reader registration (generated
876 when <option>--chkregister</option> option is used)
882 <term><errorcode>9</errorcode></term>
884 <para>Out of memory error</para>
891 <refsect1 id="seealso">
892 <title>SEE ALSO</title>
894 <refentrytitle>libxml</refentrytitle>
895 <manvolnum>3</manvolnum>
899 More information can be found at
903 <refentrytitle>libxml</refentrytitle>
904 <manvolnum>3</manvolnum>
905 </citerefentry> web page <ulink url="http://www.xmlsoft.org/"/>
909 <para>W3C <acronym>XSLT</acronym> page <ulink url="http://www.w3.org/TR/xslt"/>