xmllint.xml revision 4c76c4f7f9ec7b8855e0b9dce0c0a52e4f0a37a0
1<?xml version="1.0"?>
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" [
6]>
7<refentry>
8  <refentryinfo>
9    <title>xmllint Manual</title>
10    <copyright>
11      <year>2001</year>
12    </copyright>
13    <copyright>
14      <year>2004</year>
15    </copyright>
16    <author>
17      <firstname>John</firstname>
18      <surname>Fleck</surname>
19    </author>
20    <address><email>jfleck@inkstain.net</email></address>
21    <author>
22      <firstname>Ziying</firstname>
23      <surname>Sherwin</surname>
24    </author>
25    <address><email>sherwin@nlm.nih.gov</email></address>
26    <author>
27      <firstname>Heiko</firstname>
28      <surname>Rupp</surname>
29    </author>
30    <address><email>hwr@pilhuhn.de</email></address>
31    
32    <releaseinfo>This is release 0.4 of the xmllint Manual.</releaseinfo>
33  </refentryinfo>
34
35  <refmeta>
36    <refentrytitle>xmllint</refentrytitle>
37    <manvolnum>1</manvolnum>
38  </refmeta>
39
40  <refnamediv>
41    <refname>xmllint</refname>
42    <refpurpose>command line <acronym>XML</acronym> tool</refpurpose>
43  </refnamediv>
44
45  <refsynopsisdiv>
46    <cmdsynopsis>
47      <command>xmllint</command>
48      <group>
49	<arg>--version</arg>
50	<arg>--debug</arg>
51	<arg>--shell</arg>
52	<arg>--debugent</arg>
53	<arg>--copy</arg>
54	<arg>--recover</arg>
55	<arg>--noent</arg>
56	<arg>--nocdata</arg>
57	<arg>--nsclean</arg>
58	<arg>--noout</arg>
59	<arg>--htmlout</arg>
60	<arg>--nowrap</arg>
61	<arg>--valid</arg>
62	<arg>--postvalid</arg>
63	<arg>--dtdvalid <replaceable>URL</replaceable></arg>
64	<arg>--dtdvalidfpi <replaceable>FPI</replaceable></arg>
65	<arg>--timing</arg>
66	<arg>--repeat</arg>
67	<arg>--insert</arg>
68	<arg>--compress</arg>
69	<arg>--html</arg>
70	<arg>--push</arg>
71	<arg>--memory</arg>
72	<arg>--nowarning</arg>
73	<arg>--noblanks</arg>
74	<arg>--format</arg>
75	<arg>--testIO</arg>
76	<arg>--encode <replaceable>encoding</replaceable></arg>
77	<arg>--catalogs</arg>
78	<arg>--nocatalogs</arg>
79	<arg>--auto</arg>
80	<arg>--xinclude</arg>
81	<arg>--loaddtd</arg>
82	<arg>--dtdattr</arg>
83	<arg>--dropdtd</arg>
84	<arg>--stream</arg>
85	<arg>--chkregister</arg>
86	<arg>--relaxng</arg>
87	<arg>--schema</arg>
88	<arg>--nonet</arg>
89      </group>
90      <arg><option><replaceable>xmlfile</replaceable></option></arg>
91  </cmdsynopsis>
92  </refsynopsisdiv>
93
94  <refsect1 id="introduction">
95    <title>Introduction</title>
96    <para>
97      The xmllint program parses one or more XML files, specified on the
98      command line as <replaceable>xmlfile</replaceable>. It prints various
99      types of output, depending upon the options selected. It is useful for
100      detecting errors both in <acronym>XML</acronym> code and in the
101      <acronym>XML</acronym> parser itself.
102    </para>
103
104    <para>
105      It is included in <application>libxml2</application>.
106    </para>
107  </refsect1>
108  <refsect1 id="options">
109    <title>Options</title>
110    <variablelist>
111      <varlistentry>
112	<term><option>--version</option></term>
113	<listitem>
114	  <simpara>
115	    Display the version of
116	    <application>libxml2</application> used.
117	  </simpara>
118	</listitem>
119      </varlistentry>
120
121      <varlistentry>
122	<term><option>--debug</option></term>
123	<listitem>
124	  <simpara>
125	    Parse a file and output an annotated tree of the
126	    in-memory version of the document.
127	  </simpara>
128	</listitem>
129      </varlistentry>
130
131      <varlistentry>
132	<term><option>--shell</option></term>
133	<listitem>
134	  <simpara>
135	    Run a navigating shell. Details on available commands in shell mode
136	    are below.
137	  </simpara>
138	</listitem>
139      </varlistentry>
140
141      <varlistentry>
142	<term><option>--debugent</option></term>
143	<listitem>
144	  <simpara>
145	    Debug the entities defined in the document.
146	  </simpara>
147	</listitem>
148      </varlistentry>
149
150      <varlistentry>
151	<term><option>--copy</option> </term>
152	<listitem>
153	  <simpara>
154	    Test the internal copy implementation.
155	  </simpara>
156	</listitem>
157      </varlistentry>
158    
159      
160      <varlistentry>
161	<term><option>--recover</option></term>
162	<listitem>
163	  <simpara>
164	    Output any parsable portions of an invalid
165	    document.
166	  </simpara>
167	</listitem>
168      </varlistentry>
169
170      <varlistentry>
171	<term><option>--noent</option></term>
172	<listitem>
173	  <simpara>
174	    Substitute entity values for entity
175	    references. By default, <application>xmllint</application> leaves entity
176	    references in place.
177	  </simpara>
178	</listitem>
179      </varlistentry>
180   
181      <varlistentry>
182	<term><option>--nocdata</option></term>
183	<listitem>
184	  <simpara>
185	    Substitute CDATA section by equivalent text nodes.
186	  </simpara>
187	</listitem>
188      </varlistentry>
189   
190      <varlistentry>
191	<term><option>--nsclean</option></term>
192	<listitem>
193	  <simpara>
194	    Remove redundant namespace declarations.
195	  </simpara>
196	</listitem>
197      </varlistentry>
198   
199      <varlistentry>
200	<term><option>--noout</option></term>
201	<listitem>
202	  <simpara>
203	    Suppress output. By default,
204	    <application>xmllint</application> outputs the result tree.
205	  </simpara>
206	</listitem>
207      </varlistentry>
208
209    <varlistentry>
210	<term><option>--htmlout</option></term>
211	<listitem>
212	  <simpara>
213	    Output results as an <acronym>HTML</acronym>
214	    file. This causes <application>xmllint</application> to output
215	    the necessary <acronym>HTML</acronym> tags surrounding the result tree
216	    output so the results can be displayed in a browser. 
217	  </simpara>
218	</listitem>
219      </varlistentry>
220
221    <varlistentry>
222	<term><option>--nowrap </option></term>
223	<listitem>
224	  <simpara>
225	    Do not output HTML doc wrapper.
226	  </simpara>
227	</listitem>
228      </varlistentry>
229
230<varlistentry>
231	<term><option>--valid </option></term>
232	<listitem>
233	  <simpara>
234	    Determine if the document is a valid instance
235	    of the included Document Type Definition (<acronym>DTD</acronym>). A
236	    <acronym>DTD</acronym> to be validated against also can be specified at
237	    the command line using the <option>--dtdvalid</option> option. By default,
238	    <application>xmllint</application> also checks to determine if the
239	    document is well-formed.
240	  </simpara>
241	</listitem>
242      </varlistentry>
243   
244 <varlistentry>
245	<term><option>--postvalid</option></term>
246	<listitem>
247	  <simpara>
248	    Validate after parsing is completed.
249	  </simpara>
250	</listitem>
251      </varlistentry>
252   
253    <varlistentry>
254	<term> <option>--dtdvalid</option> <replaceable>URL</replaceable></term>
255	<listitem>
256	  <simpara>
257	    Use the
258      <acronym>DTD</acronym> specified by <replaceable>URL</replaceable> for
259      validation.
260	  </simpara>
261	</listitem>
262      </varlistentry>
263   
264    <varlistentry>
265	<term> <option>--dtdvalidfpi</option> <replaceable>FPI</replaceable></term>
266	<listitem>
267	  <simpara>
268	    Use the
269      <acronym>DTD</acronym> specified by the Public Identifier
270      <replaceable>FPI</replaceable> for validation, note that this
271      will require a Catalog exporting that Public Identifier to work.
272	  </simpara>
273	</listitem>
274      </varlistentry>
275   
276     <varlistentry>
277	<term><option>--timing</option></term>
278	<listitem>
279	  <simpara>
280	    Output information about the time it takes
281	    <application>xmllint</application> to perform the various steps.
282	  </simpara>
283	</listitem>
284      </varlistentry>
285
286   <varlistentry>
287	<term><option>--repeat</option></term>
288	<listitem>
289	  <simpara>
290	    Repeat 100 times, for timing or profiling.
291	  </simpara>
292	</listitem>
293      </varlistentry>
294   
295    <varlistentry>
296	<term><option>--insert</option></term>
297	<listitem>
298	  <simpara>
299	    Test for valid insertions.
300	  </simpara>
301	</listitem>
302      </varlistentry>
303
304      <varlistentry>
305	<term><option>--compress</option></term>
306	<listitem>
307	  <simpara>
308	    Turn on gzip compression of output.
309	  </simpara>
310	</listitem>
311      </varlistentry>
312   
313    <varlistentry>
314	<term><option>--html</option></term>
315	<listitem>
316	  <simpara>
317	    Use the <acronym>HTML</acronym> parser.
318	  </simpara>
319	</listitem>
320      </varlistentry>
321   
322    <varlistentry>
323	<term><option>--push</option></term>
324	<listitem>
325	  <simpara>
326	    Use the push mode of the parser.
327	  </simpara>
328	</listitem>
329      </varlistentry>
330   
331
332    <varlistentry>
333	<term><option>--memory</option></term>
334	<listitem>
335	  <simpara>
336	   Parse from memory.
337	  </simpara>
338	</listitem>
339      </varlistentry>
340
341    <varlistentry>
342	<term><option>--nowarning</option></term>
343	<listitem>
344	  <simpara>
345	   Do not emit warnings from the parser and/or validator.
346	  </simpara>
347	</listitem>
348      </varlistentry>
349
350    <varlistentry>
351	<term><option>--noblanks</option></term>
352	<listitem>
353	  <simpara>
354	   Drop ignorable blank spaces.
355	  </simpara>
356	</listitem>
357      </varlistentry>
358
359    <varlistentry>
360	<term><option>--format</option></term>
361	<listitem>
362	  <simpara>
363	   Reformat and reindent the output. The $XMLLINT_INDENT
364	   environment variable controls the indentation (default 
365	   value is two spaces &quot;  &quot;).
366	  </simpara>
367	</listitem>
368      </varlistentry>
369
370    <varlistentry>
371	<term><option>--testIO</option></term>
372	<listitem>
373	  <simpara>
374	   Test user input/output support.
375	  </simpara>
376	</listitem>
377      </varlistentry>
378
379    <varlistentry>
380      <term><option>--encode</option> <replaceable>encoding</replaceable></term>
381	<listitem>
382	  <simpara>
383	   Output in the given encoding.
384	  </simpara>
385	</listitem>
386      </varlistentry>
387    
388    <varlistentry>
389	<term><option>--catalogs</option></term>
390	<listitem>
391	  <simpara>
392	   Use the catalogs from $SGML_CATALOG_FILES. Otherwise /etc/xml/catalog
393	   is used by default.
394	  </simpara>
395	</listitem>
396      </varlistentry>
397
398    <varlistentry>
399	<term><option>--nocatalogs</option></term>
400	<listitem>
401	  <simpara>
402	   Do not use any catalogs.
403	  </simpara>
404	</listitem>
405      </varlistentry>
406    
407    <varlistentry>
408	<term><option>--auto</option></term>
409	<listitem>
410	  <simpara>
411	   Generate a small document for testing purposes.
412	  </simpara>
413	</listitem>
414      </varlistentry>
415
416    <varlistentry>
417	<term><option>--xinclude</option></term>
418	<listitem>
419	  <simpara>
420	   Do XInclude processing.
421	  </simpara>
422	</listitem>
423      </varlistentry>
424    <varlistentry>
425	<term><option>--loaddtd</option></term>
426	<listitem>
427	  <simpara>
428	   Fetch external DTD.
429	  </simpara>
430	</listitem>
431      </varlistentry>
432    
433    <varlistentry>
434	<term><option>--dtdattr</option></term>
435	<listitem>
436	  <simpara>
437	   Fetch external DTD and populate the tree with inherited attributes.
438	  </simpara>
439	</listitem>
440      </varlistentry>
441      <varlistentry>
442	<term><option>--dropdtd</option></term>
443	<listitem>
444	  <simpara>
445	    Remove <acronym>DTD</acronym> from output.
446	  </simpara>
447	</listitem>
448      </varlistentry>
449      <varlistentry>
450	<term><option>--stream</option></term>
451	<listitem>
452	  <simpara>Use streaming API - useful when  used  in combination with
453              --relaxng or --valid options for validation of files that are
454	    too large to be held in memory.</simpara> 
455	</listitem>
456      </varlistentry>
457      <varlistentry>
458	<term><option>--chkregister</option></term>
459	<listitem>
460	  <simpara>Turn on node registration. Useful for developeres testing
461	  libxml2 node tracking code.</simpara>
462	</listitem>
463      </varlistentry>
464      <varlistentry>
465	<term><option>--relaxng</option> <replaceable>schema</replaceable></term>
466	<listitem>
467	  <simpara>Use RelaxNG file named <replaceable>schema</replaceable> for
468	  validation.</simpara>
469	</listitem>
470      </varlistentry>
471      <varlistentry>
472	<term><option>--schema</option> <replaceable>schema</replaceable></term>
473	<listitem>
474	  <simpara>Use a W3C XML Schema file named <replaceable>schema</replaceable> for validation.</simpara>
475	</listitem>
476      </varlistentry>
477      <varlistentry>
478	<term>
479      <option>--nonet</option></term>
480	<listitem>
481	  <simpara>Do not use the Internet to fetch DTD's or entities.</simpara>
482	</listitem>
483      </varlistentry>
484    </variablelist>
485  </refsect1>
486
487  <refsect1 id="shell">
488    <title>Shell</title>
489    <para>
490      <application>xmllint</application> offers an interactive shell mode
491      invoked with the <option>--shell</option> command. Available commands in
492      shell mode include:
493    </para>
494    <variablelist>
495      <varlistentry>
496	<term><option>base</option></term>
497	<listitem>
498	  <simpara>
499	    display XML base of the node
500	  </simpara>
501	</listitem>
502      </varlistentry>
503      <varlistentry>
504	<term><option>bye</option></term>
505	<listitem>
506	  <simpara>
507	    leave shell
508	  </simpara>
509	</listitem>
510      </varlistentry>
511      <varlistentry>
512	<term><option>cat <replaceable>node</replaceable></option></term>
513	<listitem>
514	  <simpara>
515	    Display node if given or current node.
516	  </simpara>
517	</listitem>
518      </varlistentry>
519      <varlistentry>
520	<term><option>cd <replaceable>path</replaceable></option></term>
521	<listitem>
522	  <simpara>
523	    Change the current node to <replaceable>path</replaceable> (if given
524	    and unique) or root if no argument given.
525	  </simpara>
526	</listitem>
527      </varlistentry>
528      <varlistentry>
529	<term><option>dir <replaceable>path</replaceable></option></term>
530	<listitem>
531	  <simpara>
532	    Dumps information about the node (namespace, attributes, content).
533	  </simpara>
534	</listitem>
535      </varlistentry>
536      <varlistentry>
537	<term><option>du <replaceable>path</replaceable></option></term>
538	<listitem>
539	  <simpara>
540	    Show the structure of the subtree under path or the current node.
541	  </simpara>
542	</listitem>
543      </varlistentry>
544      <varlistentry>
545	<term><option>exit</option></term>
546	<listitem>
547	  <simpara>
548	    Leave the shell.
549	  </simpara>
550	</listitem>
551      </varlistentry>
552      <varlistentry>
553	<term><option>help</option></term>
554	<listitem>
555	  <simpara>
556	    Show this help.
557	  </simpara>
558	</listitem>
559      </varlistentry>
560      <varlistentry>
561	<term><option>free</option></term>
562	<listitem>
563	  <simpara>
564	    Display memory usage.
565	  </simpara>
566	</listitem>
567      </varlistentry>
568      <varlistentry>
569	<term><option>load <replaceable>name</replaceable></option></term>
570	<listitem>
571	  <simpara>
572	    Load a new document with the given name.
573	  </simpara>
574	</listitem>
575      </varlistentry>
576      <varlistentry>
577	<term><option>ls <replaceable>path</replaceable></option></term>
578	<listitem>
579	  <simpara>
580	    List contents of <replaceable>path</replaceable> (if given) or the
581	    current directory.
582	  </simpara>
583	</listitem>
584      </varlistentry>
585      <varlistentry>
586	<term><option>pwd</option></term>
587	<listitem>
588	  <simpara>
589	    Display the path to the current node.
590	  </simpara>
591	</listitem>
592      </varlistentry>
593      <varlistentry>
594	<term><option>quit</option></term>
595	<listitem>
596	  <simpara>
597	    Leave the shell.
598	  </simpara>
599	</listitem>
600      </varlistentry>
601      <varlistentry>
602	<term><option>save <replaceable>name</replaceable></option></term>
603	<listitem>
604	  <simpara>
605	    Saves the current document to <replaceable>name</replaceable> if
606	    given or to the original name.
607	  </simpara>
608	</listitem>
609      </varlistentry>
610      <varlistentry>
611	<term><option>validate</option></term>
612	<listitem>
613	  <simpara>
614	    Check the document for error.
615	  </simpara>
616	</listitem>
617      </varlistentry>
618      <varlistentry>
619	<term><option>write <replaceable>name</replaceable></option></term>
620	<listitem>
621	  <simpara>
622	    Write the current node to the given filename.
623	  </simpara>
624	</listitem>
625      </varlistentry>
626     
627    </variablelist>
628  </refsect1>
629<refsect1>
630   <title>Catalogs</title>
631     <para>Catalog behavior can be changed by redirecting
632     queries to the user's own set of catalogs. This can be done by setting the
633     <varname>XML_CATALOG_FILES</varname> environment variable to a list of
634     catalogs. An empty one should deactivate loading the default
635      <filename>/etc/xml/catalog</filename> default catalog.</para>
636  </refsect1>
637  <refsect1>
638    <title>Debugging Catalogs</title>
639    <para>Setting the environment variable <varname>XML_DEBUG_CATALOG</varname>
640    using the command <command>&quot;export XML_DEBUG_CATALOG=&quot;</command>
641    outputs debugging information related to catalog operations.</para>
642  </refsect1>
643  <refsect1>
644    <title>Error Return Codes</title>
645    <para>On the completion of execution, <application>Xmllint</application>
646    returns the following error codes:</para>
647    <variablelist>
648      <varlistentry>
649	<term>0</term>
650	<listitem>
651	  <simpara>No error</simpara>
652	</listitem>
653      </varlistentry>
654      <varlistentry>
655	<term>1</term>
656	<listitem>
657	  <simpara>Unclassified</simpara>
658	</listitem>
659      </varlistentry>
660      <varlistentry>
661	<term>2</term>
662	<listitem>
663	  <simpara>Error in DTD</simpara>
664	</listitem>
665      </varlistentry>
666      <varlistentry>
667	<term>3</term>
668	<listitem>
669	  <simpara>Validation error</simpara>
670	</listitem>
671      </varlistentry>
672      <varlistentry>
673	<term>4</term>
674	<listitem>
675	  <simpara>Validation error</simpara>
676	</listitem>
677      </varlistentry>
678      <varlistentry>
679	<term>5</term>
680	<listitem>
681	  <simpara>Error in schema compilation</simpara>
682	</listitem>
683      </varlistentry>
684      <varlistentry>
685	<term>6</term>
686	<listitem>
687	  <simpara>Error writing output</simpara>
688	</listitem>
689      </varlistentry>
690      <varlistentry>
691	<term>7</term>
692	<listitem>
693	  <simpara>Error in pattern (generated when
694	  <optional>--pattern</optional> option is used)</simpara>
695	</listitem>
696      </varlistentry>
697      <varlistentry>
698	<term>8</term>
699	<listitem>
700	  <simpara>Error in Reader registration (generated when
701	  <optional>--chkregister</optional> option is used)</simpara>
702	</listitem>
703      </varlistentry>
704      <varlistentry>
705	<term>9</term>
706	<listitem>
707	  <simpara>Out of memory error</simpara>
708	</listitem>
709      </varlistentry>
710    </variablelist>
711  </refsect1>
712</refentry>
713