Unit Test
[platform/upstream/libxml2.git] / doc / xmllint.1
1 '\" t
2 .\"     Title: xmllint
3 .\"    Author: John Fleck <jfleck@inkstain.net>
4 .\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
5 .\"      Date: $Date$
6 .\"    Manual: xmllint Manual
7 .\"    Source: libxml2
8 .\"  Language: English
9 .\"
10 .TH "XMLLINT" "1" "$Date$" "libxml2" "xmllint Manual"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18 .ie \n(.g .ds Aq \(aq
19 .el       .ds Aq '
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
24 .nh
25 .\" disable justification (adjust text to left margin only)
26 .ad l
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
30 .SH "NAME"
31 xmllint \- command line XML tool
32 .SH "SYNOPSIS"
33 .HP \w'\fBxmllint\fR\ 'u
34 \fBxmllint\fR [\fB\-\-version\fR | \fB\-\-debug\fR | \fB\-\-shell\fR | \fB\-\-xpath\ "\fR\fB\fIXPath_expression\fR\fR\fB"\fR | \fB\-\-debugent\fR | \fB\-\-copy\fR | \fB\-\-recover\fR | \fB\-\-noent\fR | \fB\-\-noout\fR | \fB\-\-nonet\fR | \fB\-\-path\ "\fR\fB\fIPATH(S)\fR\fR\fB"\fR | \fB\-\-load\-trace\fR | \fB\-\-htmlout\fR | \fB\-\-nowrap\fR | \fB\-\-valid\fR | \fB\-\-postvalid\fR | \fB\-\-dtdvalid\ \fR\fB\fIURL\fR\fR | \fB\-\-dtdvalidfpi\ \fR\fB\fIFPI\fR\fR | \fB\-\-timing\fR | \fB\-\-output\ \fR\fB\fIFILE\fR\fR | \fB\-\-repeat\fR | \fB\-\-insert\fR | \fB\-\-compress\fR | \fB\-\-html\fR | \fB\-\-xmlout\fR | \fB\-\-push\fR | \fB\-\-memory\fR | \fB\-\-maxmem\ \fR\fB\fINBBYTES\fR\fR | \fB\-\-nowarning\fR | \fB\-\-noblanks\fR | \fB\-\-nocdata\fR | \fB\-\-format\fR | \fB\-\-encode\ \fR\fB\fIENCODING\fR\fR | \fB\-\-dropdtd\fR | \fB\-\-nsclean\fR | \fB\-\-testIO\fR | \fB\-\-catalogs\fR | \fB\-\-nocatalogs\fR | \fB\-\-auto\fR | \fB\-\-xinclude\fR | \fB\-\-noxincludenode\fR | \fB\-\-loaddtd\fR | \fB\-\-dtdattr\fR | \fB\-\-stream\fR | \fB\-\-walker\fR | \fB\-\-pattern\ \fR\fB\fIPATTERNVALUE\fR\fR | \fB\-\-chkregister\fR | \fB\-\-relaxng\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-schema\ \fR\fB\fISCHEMA\fR\fR | \fB\-\-c14n\fR] {\fIXML\-FILE(S)\fR... | \-}
35 .HP \w'\fBxmllint\fR\ 'u
36 \fBxmllint\fR \fB\-\-help\fR
37 .SH "DESCRIPTION"
38 .PP
39 The
40 \fBxmllint\fR
41 program parses one or more
42 XML
43 files, specified on the command line as
44 \fIXML\-FILE\fR
45 (or the standard input if the filename provided is
46 \fB\-\fR
47 )\&. It prints various types of output, depending upon the options selected\&. It is useful for detecting errors both in
48 XML
49 code and in the
50 XML
51 parser itself\&.
52 .PP
53 \fBxmllint\fR
54 is included in
55 \fBlibxml\fR(3)\&.
56 .SH "OPTIONS"
57 .PP
58 \fBxmllint\fR
59 accepts the following options (in alphabetical order):
60 .PP
61 \fB\-\-auto\fR
62 .RS 4
63 Generate a small document for testing purposes\&.
64 .RE
65 .PP
66 \fB\-\-catalogs\fR
67 .RS 4
68 Use the
69 SGML
70 catalog(s) from
71 \fBSGML_CATALOG_FILES\fR\&. Otherwise
72 XML
73 catalogs starting from
74 /etc/xml/catalog
75 are used by default\&.
76 .RE
77 .PP
78 \fB\-\-chkregister\fR
79 .RS 4
80 Turn on node registration\&. Useful for developers testing
81 \fBlibxml\fR(3)
82 node tracking code\&.
83 .RE
84 .PP
85 \fB\-\-compress\fR
86 .RS 4
87 Turn on
88 \fBgzip\fR(1)
89 compression of output\&.
90 .RE
91 .PP
92 \fB\-\-copy\fR
93 .RS 4
94 Test the internal copy implementation\&.
95 .RE
96 .PP
97 \fB\-\-c14n\fR
98 .RS 4
99 Use the W3C
100 XML
101 Canonicalisation (C14N) to serialize the result of parsing to
102 stdout\&. It keeps comments in the result\&.
103 .RE
104 .PP
105 \fB\-\-dtdvalid \fR\fB\fIURL\fR\fR
106 .RS 4
107 Use the
108 DTD
109 specified by an
110 \fIURL\fR
111 for validation\&.
112 .RE
113 .PP
114 \fB\-\-dtdvalidfpi \fR\fB\fIFPI\fR\fR
115 .RS 4
116 Use the
117 DTD
118 specified by a Formal Public Identifier
119 \fIFPI\fR
120 for validation, note that this will require a catalog exporting that Formal Public Identifier to work\&.
121 .RE
122 .PP
123 \fB\-\-debug\fR
124 .RS 4
125 Parse a file and output an annotated tree of the in\-memory version of the document\&.
126 .RE
127 .PP
128 \fB\-\-debugent\fR
129 .RS 4
130 Debug the entities defined in the document\&.
131 .RE
132 .PP
133 \fB\-\-dropdtd\fR
134 .RS 4
135 Remove
136 DTD
137 from output\&.
138 .RE
139 .PP
140 \fB\-\-dtdattr\fR
141 .RS 4
142 Fetch external
143 DTD
144 and populate the tree with inherited attributes\&.
145 .RE
146 .PP
147 \fB\-\-encode \fR\fB\fIENCODING\fR\fR
148 .RS 4
149 Output in the given encoding\&. Note that this works for full document not fragments or result from XPath queries\&.
150 .RE
151 .PP
152 \fB\-\-format\fR
153 .RS 4
154 Reformat and reindent the output\&. The
155 \fBXMLLINT_INDENT\fR
156 environment variable controls the indentation\&. The default value is two spaces " ")\&.
157 .RE
158 .PP
159 \fB\-\-help\fR
160 .RS 4
161 Print out a short usage summary for
162 \fBxmllint\fR\&.
163 .RE
164 .PP
165 \fB\-\-html\fR
166 .RS 4
167 Use the
168 HTML
169 parser\&.
170 .RE
171 .PP
172 \fB\-\-htmlout\fR
173 .RS 4
174 Output results as an
175 HTML
176 file\&. This causes
177 \fBxmllint\fR
178 to output the necessary
179 HTML
180 tags surrounding the result tree output so the results can be displayed/viewed in a browser\&.
181 .RE
182 .PP
183 \fB\-\-insert\fR
184 .RS 4
185 Test for valid insertions\&.
186 .RE
187 .PP
188 \fB\-\-loaddtd\fR
189 .RS 4
190 Fetch an external
191 DTD\&.
192 .RE
193 .PP
194 \fB\-\-load\-trace\fR
195 .RS 4
196 Display all the documents loaded during the processing to
197 stderr\&.
198 .RE
199 .PP
200 \fB\-\-maxmem \fR\fB\fINNBYTES\fR\fR
201 .RS 4
202 Test the parser memory support\&.
203 \fINNBYTES\fR
204 is the maximum number of bytes the library is allowed to allocate\&. This can also be used to make sure batch processing of
205 XML
206 files will not exhaust the virtual memory of the server running them\&.
207 .RE
208 .PP
209 \fB\-\-memory\fR
210 .RS 4
211 Parse from memory\&.
212 .RE
213 .PP
214 \fB\-\-noblanks\fR
215 .RS 4
216 Drop ignorable blank spaces\&.
217 .RE
218 .PP
219 \fB\-\-nocatalogs\fR
220 .RS 4
221 Do not use any catalogs\&.
222 .RE
223 .PP
224 \fB\-\-nocdata\fR
225 .RS 4
226 Substitute CDATA section by equivalent text nodes\&.
227 .RE
228 .PP
229 \fB\-\-noent\fR
230 .RS 4
231 Substitute entity values for entity references\&. By default,
232 \fBxmllint\fR
233 leaves entity references in place\&.
234 .RE
235 .PP
236 \fB\-\-nonet\fR
237 .RS 4
238 Do not use the Internet to fetch
239 DTDs or entities\&.
240 .RE
241 .PP
242 \fB\-\-noout\fR
243 .RS 4
244 Suppress output\&. By default,
245 \fBxmllint\fR
246 outputs the result tree\&.
247 .RE
248 .PP
249 \fB\-\-nowarning\fR
250 .RS 4
251 Do not emit warnings from the parser and/or validator\&.
252 .RE
253 .PP
254 \fB\-\-nowrap\fR
255 .RS 4
256 Do not output
257 HTML
258 doc wrapper\&.
259 .RE
260 .PP
261 \fB\-\-noxincludenode\fR
262 .RS 4
263 Do XInclude processing but do not generate XInclude start and end nodes\&.
264 .RE
265 .PP
266 \fB\-\-nsclean\fR
267 .RS 4
268 Remove redundant namespace declarations\&.
269 .RE
270 .PP
271 \fB\-\-output \fR\fB\fIFILE\fR\fR
272 .RS 4
273 Define a file path where
274 \fBxmllint\fR
275 will save the result of parsing\&. Usually the programs build a tree and save it on
276 stdout, with this option the result
277 XML
278 instance will be saved onto a file\&.
279 .RE
280 .PP
281 \fB\-\-path "\fR\fB\fIPATH(S)\fR\fR\fB"\fR
282 .RS 4
283 Use the (space\- or colon\-separated) list of filesystem paths specified by
284 \fIPATHS\fR
285 to load
286 DTDs or entities\&. Enclose space\-separated lists by quotation marks\&.
287 .RE
288 .PP
289 \fB\-\-pattern \fR\fB\fIPATTERNVALUE\fR\fR
290 .RS 4
291 Used to exercise the pattern recognition engine, which can be used with the reader interface to the parser\&. It allows to select some nodes in the document based on an XPath (subset) expression\&. Used for debugging\&.
292 .RE
293 .PP
294 \fB\-\-postvalid\fR
295 .RS 4
296 Validate after parsing has completed\&.
297 .RE
298 .PP
299 \fB\-\-push\fR
300 .RS 4
301 Use the push mode of the parser\&.
302 .RE
303 .PP
304 \fB\-\-recover\fR
305 .RS 4
306 Output any parsable portions of an invalid document\&.
307 .RE
308 .PP
309 \fB\-\-relaxng \fR\fB\fISCHEMA\fR\fR
310 .RS 4
311 Use RelaxNG file named
312 \fISCHEMA\fR
313 for validation\&.
314 .RE
315 .PP
316 \fB\-\-repeat\fR
317 .RS 4
318 Repeat 100 times, for timing or profiling\&.
319 .RE
320 .PP
321 \fB\-\-schema \fR\fB\fISCHEMA\fR\fR
322 .RS 4
323 Use a W3C
324 XML
325 Schema file named
326 \fISCHEMA\fR
327 for validation\&.
328 .RE
329 .PP
330 \fB\-\-shell\fR
331 .RS 4
332 Run a navigating shell\&. Details on available commands in shell mode are below (see
333 the section called \(lqSHELL COMMANDS\(rq)\&.
334 .RE
335 .PP
336 \fB\-\-xpath "\fR\fB\fIXPath_expression\fR\fR\fB"\fR
337 .RS 4
338 Run an XPath expression given as argument and print the result\&. In case of a nodeset result, each node in the node set is serialized in full in the output\&. In case of an empty node set the "XPath set is empty" result will be shown and an error exit code will be returned\&.
339 .RE
340 .PP
341 \fB\-\-stream\fR
342 .RS 4
343 Use streaming
344 API
345 \- useful when used in combination with
346 \fB\-\-relaxng\fR
347 or
348 \fB\-\-valid\fR
349 options for validation of files that are too large to be held in memory\&.
350 .RE
351 .PP
352 \fB\-\-testIO\fR
353 .RS 4
354 Test user input/output support\&.
355 .RE
356 .PP
357 \fB\-\-timing\fR
358 .RS 4
359 Output information about the time it takes
360 \fBxmllint\fR
361 to perform the various steps\&.
362 .RE
363 .PP
364 \fB\-\-valid\fR
365 .RS 4
366 Determine if the document is a valid instance of the included Document Type Definition (DTD)\&. A
367 DTD
368 to be validated against also can be specified at the command line using the
369 \fB\-\-dtdvalid\fR
370 option\&. By default,
371 \fBxmllint\fR
372 also checks to determine if the document is well\-formed\&.
373 .RE
374 .PP
375 \fB\-\-version\fR
376 .RS 4
377 Display the version of
378 \fBlibxml\fR(3)
379 used\&.
380 .RE
381 .PP
382 \fB\-\-walker\fR
383 .RS 4
384 Test the walker module, which is a reader interface but for a document tree, instead of using the reader
385 API
386 on an unparsed document it works on an existing in\-memory tree\&. Used for debugging\&.
387 .RE
388 .PP
389 \fB\-\-xinclude\fR
390 .RS 4
391 Do XInclude processing\&.
392 .RE
393 .PP
394 \fB\-\-xmlout\fR
395 .RS 4
396 Used in conjunction with
397 \fB\-\-html\fR\&. Usually when
398 HTML
399 is parsed the document is saved with the
400 HTML
401 serializer\&. But with this option the resulting document is saved with the
402 XML
403 serializer\&. This is primarily used to generate
404 XHTML
405 from
406 HTML
407 input\&.
408 .RE
409 .SH "SHELL COMMANDS"
410 .PP
411 \fBxmllint\fR
412 offers an interactive shell mode invoked with the
413 \fB\-\-shell\fR
414 command\&. Available commands in shell mode include (in alphabetical order):
415 .PP
416 \fBbase\fR
417 .RS 4
418 Display
419 XML
420 base of the node\&.
421 .RE
422 .PP
423 \fBbye\fR
424 .RS 4
425 Leave the shell\&.
426 .RE
427 .PP
428 \fBcat \fR\fB\fINODE\fR\fR
429 .RS 4
430 Display the given node or the current one\&.
431 .RE
432 .PP
433 \fBcd \fR\fB\fIPATH\fR\fR
434 .RS 4
435 Change the current node to the given path (if unique) or root if no argument is given\&.
436 .RE
437 .PP
438 \fBdir \fR\fB\fIPATH\fR\fR
439 .RS 4
440 Dumps information about the node (namespace, attributes, content)\&.
441 .RE
442 .PP
443 \fBdu \fR\fB\fIPATH\fR\fR
444 .RS 4
445 Show the structure of the subtree under the given path or the current node\&.
446 .RE
447 .PP
448 \fBexit\fR
449 .RS 4
450 Leave the shell\&.
451 .RE
452 .PP
453 \fBhelp\fR
454 .RS 4
455 Show this help\&.
456 .RE
457 .PP
458 \fBfree\fR
459 .RS 4
460 Display memory usage\&.
461 .RE
462 .PP
463 \fBload \fR\fB\fIFILENAME\fR\fR
464 .RS 4
465 Load a new document with the given filename\&.
466 .RE
467 .PP
468 \fBls \fR\fB\fIPATH\fR\fR
469 .RS 4
470 List contents of the given path or the current directory\&.
471 .RE
472 .PP
473 \fBpwd\fR
474 .RS 4
475 Display the path to the current node\&.
476 .RE
477 .PP
478 \fBquit\fR
479 .RS 4
480 Leave the shell\&.
481 .RE
482 .PP
483 \fBsave \fR\fB\fIFILENAME\fR\fR
484 .RS 4
485 Save the current document to the given filename or to the original name\&.
486 .RE
487 .PP
488 \fBvalidate\fR
489 .RS 4
490 Check the document for errors\&.
491 .RE
492 .PP
493 \fBwrite \fR\fB\fIFILENAME\fR\fR
494 .RS 4
495 Write the current node to the given filename\&.
496 .RE
497 .SH "ENVIRONMENT"
498 .PP
499 \fBSGML_CATALOG_FILES\fR
500 .RS 4
501 SGML
502 catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
503 \fBSGML_CATALOG_FILES\fR
504 environment variable to a list of catalogs\&. An empty one should deactivate loading the default
505 /etc/sgml/catalog
506 catalog\&.
507 .RE
508 .PP
509 \fBXML_CATALOG_FILES\fR
510 .RS 4
511 XML
512 catalog behavior can be changed by redirecting queries to the user\*(Aqs own set of catalogs\&. This can be done by setting the
513 \fBXML_CATALOG_FILES\fR
514 environment variable to a list of catalogs\&. An empty one should deactivate loading the default
515 /etc/xml/catalog
516 catalog\&.
517 .RE
518 .PP
519 \fBXML_DEBUG_CATALOG\fR
520 .RS 4
521 Setting the environment variable
522 \fBXML_DEBUG_CATALOG\fR
523 to
524 \fInon\-zero\fR
525 using the
526 \fBexport\fR
527 command outputs debugging information related to catalog operations\&.
528 .RE
529 .PP
530 \fBXMLLINT_INDENT\fR
531 .RS 4
532 Setting the environment variable
533 \fBXMLLINT_INDENT\fR
534 controls the indentation\&. The default value is two spaces " "\&.
535 .RE
536 .SH "DIAGNOSTICS"
537 .PP
538 \fBxmllint\fR
539 return codes provide information that can be used when calling it from scripts\&.
540 .PP
541 \fB0\fR
542 .RS 4
543 No error
544 .RE
545 .PP
546 \fB1\fR
547 .RS 4
548 Unclassified
549 .RE
550 .PP
551 \fB2\fR
552 .RS 4
553 Error in
554 DTD
555 .RE
556 .PP
557 \fB3\fR
558 .RS 4
559 Validation error
560 .RE
561 .PP
562 \fB4\fR
563 .RS 4
564 Validation error
565 .RE
566 .PP
567 \fB5\fR
568 .RS 4
569 Error in schema compilation
570 .RE
571 .PP
572 \fB6\fR
573 .RS 4
574 Error writing output
575 .RE
576 .PP
577 \fB7\fR
578 .RS 4
579 Error in pattern (generated when
580 \fB\-\-pattern\fR
581 option is used)
582 .RE
583 .PP
584 \fB8\fR
585 .RS 4
586 Error in Reader registration (generated when
587 \fB\-\-chkregister\fR
588 option is used)
589 .RE
590 .PP
591 \fB9\fR
592 .RS 4
593 Out of memory error
594 .RE
595 .SH "SEE ALSO"
596 .PP
597 \fBlibxml\fR(3)
598 .PP
599 More information can be found at
600 .sp
601 .RS 4
602 .ie n \{\
603 \h'-04'\(bu\h'+03'\c
604 .\}
605 .el \{\
606 .sp -1
607 .IP \(bu 2.3
608 .\}
609 \fBlibxml\fR(3)
610 web page
611 \m[blue]\fB\%http://www.xmlsoft.org/\fR\m[]
612 .RE
613 .sp
614 .RS 4
615 .ie n \{\
616 \h'-04'\(bu\h'+03'\c
617 .\}
618 .el \{\
619 .sp -1
620 .IP \(bu 2.3
621 .\}
622 W3C
623 XSLT
624 page
625 \m[blue]\fB\%http://www.w3.org/TR/xslt\fR\m[]
626 .RE
627 .sp
628 .SH "AUTHORS"
629 .PP
630 \fBJohn Fleck\fR <\&jfleck@inkstain\&.net\&>
631 .RS 4
632 Author.
633 .RE
634 .PP
635 \fBZiying Sherwin\fR <\&sherwin@nlm\&.nih\&.gov\&>
636 .RS 4
637 Author.
638 .RE
639 .PP
640 \fBHeiko Rupp\fR <\&hwr@pilhuhn\&.de\&>
641 .RS 4
642 Author.
643 .RE
644 .SH "COPYRIGHT"
645 .br
646 Copyright \(co 2001, 2004
647 .br