summarylogtreecommitdiffstats
path: root/xmltool.1
blob: d763edd1011ab9432b27a5cd3a86de72f56ecb5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
.TH XXETOOL 1 "2021" "xmltool" "User Commands"
.
.SH NAME
.
xxetool \- database frontend
.
.SH SYNOPSIS
.
.B xmltool validate
[\fIVALIDATE OPTIONS\fR] [\fICOMMON OPTIONS\fR]
[\fIxml_files\fR]
.br
.
.B xmltool  indent
[\fIINDENT OPTIONS\fR] [\fICOMMON OPTIONS\fR]
[\fIxml_files\fR]
.br
.
.B xmltool schematron
[\fISCHEMATRON OPTIONS\fR] [\fICOMMON OPTIONS\fR]
.I shematron
[\fIxml_files\fR]
.br
.
.B xmltool  schemadoc
[\fISCHEMADOC OPTIONS\fR] [\fICOMMON OPTIONS\fR]
.I schema
.I doc_dir
.
.SH DESCRIPTION
The xmltool command-line utility can be used to validate and pretty-print (i.e. indent) XML documents and also to automatically generate a reference manual in HTML format for a schema.

The xmltool utility comprises 4 different processors:

.SS validate

Checks the validity of a document conforming to a DTD, W3C XML Schema or RELAX NG schema. May also be used to check the validity of a DTD, W3C XML Schema or RELAX NG schema.

.SS indent

Saves one or more documents after reformatting their XML contents. May be also used to flatten these documents, that is, to transclude XInclude elements or DITA conrefs.

.SS schematron

Checks the validity of a document against a Schematron schema. May also be used to check the validity of a Schematron schema.

.SS schemadoc

Generates a reference manual in HTML format for a DTD, W3C XML Schema or RELAX NG schema.

The generated HTML reference manual, organized like "DocBook: The Definitive Guide" by Norman Walsh and al., lists all the elements and attributes specified in the schema.
This manual is intended to help content authors create instances conforming to a given schema. This manual is not intended to help schema authors document their design.
Note that, for now, this documentation generator cannot extract documentation contained in a schema (i.e. in annotation/documentation elements) and merge extracted documentation with automatically generated documentation.
.
.SH VALIDATE OPTIONS
.
Validates specified XML files. If no XML files are specified, it is the schemas specified using the 
.B -s
option which are validated.    
.
.TP
.BI -s \ schema
Use specified
.I schema
file to validate all specified XML files.

.I schema
must be a DTD having a
.B .dtd
extension or a W3C XML Schema having a 
.BR .xsd , \ .xs , \ .wxs
extension or a RELAX NG schema having a 
.BR .rng , \ .rnc
(compact syntax) extension.

By default, the
.I schema
used for validation is found in each specified XML file (e.g. \fB<!DOCTYPE>\fR).

It is possible to specify several 
.B -s
options:

    When no XML files are specified, each schema is individually validated.

    When several XML files are specified, the schemas are composed to form a compound schema (e.g. DocBook 5+MathML) and this compound schema is used to validate specified XML files.
.
.TP
.B -l
Give priority to the schemas locally specified in the file (e.g. \fB<!DOCTYPE>\fR) to be validated over those specified using the
.B -s
option. Ignored unless the
.B -s
option is used too.
.
.TP
.B -f
When validating a document, ignore false duplicate ID errors caused by multiple inclusions of the same element. When saving a document, replace such false duplicate IDs by automatically generated ones.
.
.SH VALIDATION EXAMPLES
.
.TP
Validate docbook-image.xml against the DTD specified in its <!DOCTYPE>:

cd /usr/share/doc/xxe/demo

.B xmltool validate
docbook-image.xml
.
.TP
Validate docbook-table.xml and docbook-image.xml against the DocBook 4.5 DTD:

cd /usr/share/doc/xxe/demo

.B xmltool validate -s
/usr/share/java/xxe/addon/config/docbook/dtd/V4.5/docbookx.dtd \\
    docbook-table.xml docbook-image.xml
.
.TP
Validate the DocBook 4.5 DTD:

cd /usr/share/doc/xxe/demo

.B xmltool validate -s
/usr/share/java/xxe/addon/config/docbook/dtd/V4.5/docbookx.dtd
.
.TP
Validate sample.xml against the combined docbook.rng and mathml2.rng RELAX NG schemas:

cd /usr/share/java/xxe/addon/mathml_config/db5mml

.B xmltool validate \fR\\
    \fB-s\fR ../../config/docbook5/rng/V5.0/docbook.rng \\
    \fB-s\fR rng/mathml2.rng \\
    sample.xml
.
.TP
Note that the combined schemas don't need to be of the same kind:

cd /usr/share/java/xxe/addon/mathml_config/db5mml

.B xmltool validate \fR\\
    \fB-s\fR ../../config/docbook5/rng/V5.0/docbook.rng \\
    \fB-s\fR ../standalone/xsd/mathml2.xsd \\
    sample.xml
.
.SH INDENT OPTIONS
.
Save, possibly indenting and / or flattening, specified XML files.
.
.TP
.BI -o \ save_file_or_dir

Specifies where to save all specified documents.

If a single document is to be saved, 
.I save_file_or_dir
may specify a file or an existing directory.

If multiple documents are to be saved,
.I save_file_or_dir
must specify a directory. Such directory is automatically created if it does not already exist.

Default: reuse the original filename of each specified document after renaming this document using a 
.B .BAK
filename.
.
.TP
.B -flat

Do not preserve inclusions. Instead "flatten" the document.

This option automatically generates
.B xml:base
attribute when needed to. Note that
.B xml:base
attributes are added even when this attribute is not allowed by the schema of the document being indented.

Default: preserve inclusions.
.
.TP
.BI -indent \ integer

Specifies the number of space characters used to indent a child element relatively to its parent element.

    A positive or null value means: indent always.

    Value 
.B -1
means: never indent.

    Any other negative value means indent, but only if the document to be saved has an actual document type. In such case, the number of space characters is: (\fB-2\fR - \fIinteger\fR).

Default:
.BR -4 .
.
.TP
.BI -maxlinelength \ positive_integer

Specifies the maximum line length for elements containing text interspersed with child elements.

Default:
.BR 78 .
.
.TP
.B -noopenlines

Do not add open lines between the child elements of elements having an "element-only" content model.

Default: add open lines.
.
.TP
.B -xhtml

Favor the interoperability with HTML as recommended in the XHTML spec.

In practice, if this option has been specified:

    Empty elements having a non empty content are saved as "<tag></tag>".

    Empty elements having an empty content are saved as "<tag />" (with a space after the tag).

Note that specifying this option for document types other than XHTML does not really make sense.

Default: do not favor the interoperability with HTML.
.
.TP
.B -nocharentities

Do not save characters not supported by the encoding as entity references. Instead, save them as numeric references.

Default: when possible and when needed to, save characters as entity references.
.
.TP
.BI -specialchars \ list_of_chars_or_char_ranges

Always save specified characters as entity references.

Example:
.B -specialchars
"reg 174 0x00ae 0256 pound:yen 163:165 0xA3:0xA5 0243:0245".

No default.
.
.TP
.BI -cdatasections \ list_of_simple_XPaths

Save the textual contents of specified elements as CDATA sections.

XHTML example:
.B -cdatasections
"htm:script htm:style".

No default.
.
.TP
.B -prefix \fIprefix namespace

Associates a
.I prefix
to a namespace.

Multiple 
.B -prefix
options are allowed.

This may be needed to allow parsing the XPaths argument of the above 
.B -cdatasections
option. Options
.B -prefix
must precede the
.B -cdatasections
option.

XHTML example:
.B -prefix htm http://www.w3.org/1999/xhtml\fR.

No default.
.
.TP
.B -nooriginalprefixes

Do not use the namespace prefixes originally specified in the document. Instead, generate prefixes.

Default: Reuse the original prefixes as much as possible.
.
.TP
.B -nodefaultnamespace

Do not use the default namespace originally specified in the document.

Default: Reuse the default namespace if any.
.
.TP
.B -xmlversion 1.0\fR|\fB1.1\fR|\fBoriginal

Specifies the 
.B version
pseudo-attribute of the XML declaration. 
.B original
means: reuse the XML version originally specified in the document.

Default: original.
.
.TP
.B -encoding \fIjava_supported_encoding\fR|\fBoriginal

Specifies which encoding to use when saving a document. 
.B original
means: reuse the encoding originally specified in the 
.B encoding
pseudo-attribute of the XML declaration of the document.

Default: original.
.
.TP
.B -standalone yes\fR|\fBno\fR|\fBoriginal

Specifies the 
.B standalone
pseudo-attribute of the XML declaration. 
.B original
means: reuse the 
.B standalone
pseudo-attribute originally specified in the document.

No default: do not add a "standalone" pseudo-attribute to the XML declaration.
.
.TP
.B -noinvalid

Do not save specified documents if any of them is found to have validity errors (even harmless cross-reference errors).

Default: save documents even if some of them are found to be invalid.
.
.TP
.BI -script \ URL_or_filename

Run specified .xed script in order to modify the document before saving it to disk. Note that it's possible to specify the
.B -script
option several times in order to use several scripts in turn.
.
.SH INDENTION EXAMPLES
.
.TP
Indent docbook-table.xml using the default settings. The original docbook-table.xml is saved to docbook-table.xml.BAK.

cd /usr/share/doc/xxe/demo

.B xmltool indent
docbook-table.xml

.B ls
docbook-table.xml*

docbook-table.xml docbook-table.xml.BAK
.
.TP
Indent docbook-table.xml using specified settings. Save indented file to out.xml.

cd /usr/share/doc/xxe/demo

.B xmltool indent -indent
1
.B -noopenlines -nolegacy -o 
out.xml docbook-table.xml
.
.TP
Force the indentation of schema-less file xhtml_strict.xxe.

cd /usr/share/java/xxe/addon/config/xhtml

.B xmltool indent -indent
2
.B -o
indented.xxe xhtml_strict.xxe 

WARNING: Cannot determine which schema to use for validating "xhtml_strict.xxe"
.
.TP
Indent all .xhtml files contained in current directory. Create save files in directory /tmp/out/.

cd /usr/share/doc/xxe/demo

.B xmltool indent -v -encoding
Windows-1252
.B -o
/tmp/out *.xhtml
.
.TP
Transclude all XInclude elements contained docbook-modular-book.xml (\fB-f\fR is needed otherwise out.xml would contain a number of duplicate ID errors).

cd /usr/share/doc/xxe/demo

.B xmltool indent -xi -f -flat -o
out.xml docbook-modular-book.xml
.
.TP
Modify doc.xml using edit.xed before saving it, indented, to /tmp/out.xml.

cd /usr/share/doc/xxe/demo

.B xmltool indent -script
edit.xed
.B -o
/tmp/out.xml doc.xml
.
.SH SCHEMATRON OPTIONS
.
Validate specified XML documents against specified Schematron.

Optionally validate the Schematron itself.

Unless the 
.B -iso
option is used, the Schematron may be embedded in another type of XML document (e.g. a DocBook 5 RELAX NG grammar not using the compact syntax).
.
.TP
.B -iso

Fully validate the Schematron as an ISO Schematron schema.

Default: do not validate the Schematron, just load it.

Note that the Schematron loader is very lenient and accepts ISO Schematron as well as Schematron 1.5 schemas.
.
.TP
.BI -o \ out_schematron_file

Save the Schematron to specified file. The written schema is in all cases an ISO Schematron schema using the minimal syntax.
.
.TP
.BI -phase \ phase_id

Specifies the ID of the phase which is to be used for validation. May also be #ALL or #DEFAULT.

Default:
.BR #DEFAULT ,
if any,
.B #ALL
otherwise.
.
.TP
.B -var \fIname value

Specify overrides for some of the let variables defined in the Schematron.

Note that value must be a valid XPath expression and not a plain string.
.
.SH SCHEMATRON EXAMPLES
.
.TP
Validate docbook.sch as an ISO Schematron schema. Additionally save a copy in /tmp/out.sch.

cd /usr/share/java/xxe/addon/config/docbook

.B xmltool schematron -iso -o
/tmp/out.sch docbook.sch
.
.TP
Validate docbook-image.xml against docbook.sch.

cd /usr/share/doc/xxe/demo

.B xmltool schematron
\\
    /usr/share/java/xxe/addon/config/docbook/docbook.sch \\
    docbook-image.xml
.
.TP
Validate docbook-image.xml against docbook.sch, using phase #ALL. Pass to the Schematron variable foo having XPath string literal "bar" as its value.

cd /usr/share/doc/xxe/demo

.B xmltool schematron -phase
\'#ALL\'
.B -var
foo '"bar"' \\
    /usr/share/java/xxe/addon/config/docbook/docbook.sch \\
    docbook-image.xml
.
.SH SCHEMADOC OPTIONS
.
Generate in directory
.I doc_dir
a reference manual in HTML format for schema file
.IR schema .

.I Schema
must be a DTD having a
.B .dtd
extension or a W3C XML Schema having a 
.BR .xsd ,
.BR .xs \ or \ .wxs
extension or a RELAX NG schema having a 
.BR .rng \ or \ .rnc
(compact syntax) extension.

.I doc_dir
is automatically created if it does not exist.
.
.TP
.BI -css \ css_url

Specifies the URL of the CSS style sheet used for the generated HTML.

Default: generated HTML does not have a <link rel="stylesheet">.
.
.TP
.BI -charset\  encoding

Specifies the charset used for the generated HTML.

Default: use platform default encoding and generated HTML does not have a <meta http-equiv="Content-Type">.
.
.TP
.B -xxe

Generate annotations which are meaningful when using the schema with XMLmind XML Editor.
.
.SH SCHEMADOC EXAMPLE
.
.TP
cd /usr/share/doc/xxe/demo

.B xmltool schemadoc
bugreport/bugreport.xsd /tmp/bugreport_doc

.B ls
/tmp/bugreport_doc

a__6sv96.html abbr__79rrv.html ... \fBindex.html\fR ... workaround__jus1.html
.
.SH COMMON OPTIONS
.
.TP
.B -xi

When loading a document, transclude XInclude elements.

Default: XInclude elements are treated as any other element.

This option is equivalent to "-inclscheme com.xmlmind.xml.xinclude.XIncludeScheme".
.
.TP
.BI -inclscheme \ class_name

When loading a document, transclude nodes specifying an inclusion directive belonging to specified inclusion scheme.

Default: nodes specifying an inclusion directive are treated as any other node.

Specifying several -inclscheme options is permitted. Mixing 
.B -xi
and
.B -inclscheme
options is permitted.
.
.TP
.BI -cache \ schema_cache_dir

Specifies the directory to be used as a schema cache. This directory is automatically created if it does not exist.

Default: do not cache schemas.

RELAX NG schemas can be cached only in memory and not on disk.
.
.TP
.BI -rncencoding \ encoding

Specifies the
.I encoding
used for RELAX NG compact syntax schemas.

Default: do not cache schemas.
.
.TP
.B -v

Verbose.
.
.SH COMMON OPTIONS EXAMPLES
.
.TP
Transclude all XInclude elements contained docbook-modular-book.xml (\fB-f\fR is needed otherwise out.xml would contain a number of duplicate ID errors).

cd /usr/share/doc/xxe/demo

.B xmltool indent -xi -f -flat -o 
out.xml docbook-modular-book.xml
.
.TP
Transclude all conref elements contained in topic1.dita.

cd /tmp

.B xmltool indent -inclscheme 
"com.xmlmind.xmleditext.dita.ConrefScheme" \\
    \fB-f -flat -o\fR out.dita topic1.dita 
.
.TP
Validate docbook-table.xml. Cache the DocBook DTD if it is not already cached. If it is already cached, use the cached copy.

cd /usr/share/doc/xxe/demo

.B xmltool validate -cache 
/tmp/cache docbook-table.xml

.B ls
/tmp/cache

directory.txt docbookx.ser
.
.TP
Validate mathml.pane against pane.rnc, a RELAX NG schema using the compact syntax, encoded in ISO-8859-1.

cd /usr/share/java/xxe/addon/mathml_config/common/pane

.B xmltool validate
\\
    \fB-rncencoding\fR ISO-8859-1 \\
    \fB-s\fR pane.rnc \\
    mathml.pane
.
.
.SH ABOUT THIS MANPAGE
.
This manual page was created from http://www.xmlmind.com/xmleditor/_distrib/doc/xmltool/index.html and refers to the version from 5. March 2021.

An offline html version of that web site is found at /usr/share/doc/xxe/doc/xmltool/index.html

Similarly, a PDF variant is located at /usr/share/doc/xxe/doc/xmltool/xmltool.pdf