@@ -7,9 +7,17 @@ integrate the resolver into other applications.
7
7
8
8
## What is it?
9
9
10
- A simple application that performs
10
+ A simple application that has three features:
11
11
12
- 1 . Well-formed or validating parses of XML documents.
12
+ 1 . It can parse a document and perform validation and transformation on it.
13
+ 2 . It can perform specific lookup operations in a set of catalogs.
14
+ 3 . It can show the catalog entries found by the resolver in a set of catalogs.
15
+
16
+ ### Validation and parsing
17
+
18
+ Four operations can be performed on a document:
19
+
20
+ 1 . Well-formed or validating parsing.
13
21
2 . XML Schema validation with Xerces.
14
22
3 . RELAX NG validation with Jing.
15
23
4 . XSLT transformations with Saxon-HE.
@@ -18,15 +26,26 @@ Parsing XML documents demonstrates how external identifiers are
18
26
resolved. The other features demonstrate various forms of URI
19
27
resolution.
20
28
29
+ ### Lookup operations
30
+
31
+ Performs specific lookup operations (system, public, entity, URI,
32
+ etc.) and returns the resolved URI from a set of catalogs.
33
+
34
+ ### Showing catalog entries
35
+
36
+ Displays all (or a subset) of the entries in a set of catalogs. This
37
+ displays what the catalog parser determined to be the valid entries in
38
+ the catalogs.
39
+
21
40
## What does it do?
22
41
23
42
The point of the application is to demonstrate how the resolver works;
24
43
the validation outcomes and XSLT results are not the
25
44
most important part.
26
45
27
- The application installs a very “chatty” resolver that will print
28
- information about each request, how it was processed, and what was
29
- returned. For example:
46
+ The parsing application installs a very “chatty” resolver that will
47
+ print information about each request, how it was processed, and what
48
+ was returned. For example:
30
49
31
50
```
32
51
✗ Resolved: [dtd]: https://example.com/sample.dtd (-//Example//DTD Sample v1.0//EN)
@@ -51,46 +70,71 @@ comes from a `jar:` or `classpath:` URI.
51
70
52
71
## Command line options
53
72
54
- Running the application with no arguments will print a summary of the
73
+ Running the application with no arguments will a summary of the
55
74
command line options:
56
75
57
76
```
58
- $ java -jar sampleapp-3.0.1beta3.jar
59
- Usage: org.xmlresolver.example.SampleApp [options] document.xml
60
-
61
- Options:
62
- -dtd Perform a (DTD) validating parse of the document
63
- -xsd:file Perform XML Schema validation with XML Schema ‘file’
64
- -rng:file Perform RELAX NG validation with RELAX NG grammar ‘file’
65
- -xsl:file Perform an XSLT transformation with stylesheet ‘file’
66
- -catalog:file Use ‘file’ as an XML Catalog
67
- -cache[:dir] Enable caching (using ‘dir’ as the cache directory)
68
- -validate Validate catalog files when they’re loaded
69
- -[no-]resolver [Don't] use the resolver (the default)
70
- -[no-]classpath-catalogs [Don't] search the classpath for catalogs
71
- -help Print this usage message
72
-
73
- The -catalog and -xsd options may be repeated.
74
- ```
75
-
76
- The filename you provide will be parsed and processed according to the
77
- options provided:
78
-
79
- * ` -dtd ` enables DTD validation during the initial parse
80
- * ` -xsd ` enables XML Schema validation with the specified schema(s)
81
- * ` -rng ` enables RELAX NG validation with the specified grammar
82
- * ` -xsl ` enables XSLT transformation with the specified stylesheet
83
- * ` -catalog ` allows you to specify one or more catalogs to use
84
- * ` -cache ` enables caching. If you specify a directory, it will be used
85
- as the cache directory. If you don’t specify a directory, the default
86
- is ` ./xmlresolver-cache ` .
87
- * ` -validate ` enables validation * of the XML Catalog files* ; this has nothing
88
- to do with the main document being processed
89
- * ` -no-resolver ` will disable the resolver entirely. By default, the resolver
90
- will be used.
91
- * ` -no-classpath-catalogs ` will disable automatic searching for catalogs on
92
- the classpath. By default, the resolver will search for catalogs in
93
- ` org/xmlresolver/catalog.xml ` on the classpath.
77
+ $ java -jar sampleapp-3.0.1-SNAPSHOT.jar
78
+ Usage: SampleApp [options] [command] [command options]
79
+ Options:
80
+ -help, -h, --help
81
+ Display help
82
+ -cache
83
+ Enable caching
84
+ Default: false
85
+ -cache-directory, -cache-dir
86
+ Directory to use for caching (implies -cache)
87
+ -catalog
88
+ Use XML Catalog for resolution
89
+ Default: []
90
+ -classpath-catalogs, -cp
91
+ Search the classpath for catalogs
92
+ Default: true
93
+ -resolver
94
+ Use the XML Resolver during processing
95
+ Default: true
96
+ -validate
97
+ Validate catalog files
98
+ Default: false
99
+ Commands:
100
+ parse Parse, validate, and/or transform a document
101
+ Usage: parse [options] The document to process
102
+ Options:
103
+ -dtd
104
+ Perform a (DTD) validating parse
105
+ Default: false
106
+ -rng
107
+ Perform RELAX NG validation with grammar
108
+ -xsd
109
+ Perform XML Schema validation with schema(s)
110
+ Default: []
111
+ -xsl
112
+ Transform the document wht the XSL stylesheet
113
+
114
+ lookup Lookup entries in the catalog(s)
115
+ Usage: lookup [options]
116
+ Options:
117
+ -name
118
+ Specify the doctype or entity name
119
+ -nature
120
+ Specify the namespace nature
121
+ -public
122
+ Specify the public identifier
123
+ -purpose
124
+ Specify the namespace purpose
125
+ -system
126
+ Specify the system identifier
127
+ -type
128
+ Perform lookup of a particular type
129
+ -uri
130
+ Specify the URI
131
+
132
+ show Show the content of the catalog(s)
133
+ Usage: show [options]
134
+ Options:
135
+ -regex, -r
136
+ A regular expression to filter the entries shown
137
+ ```
94
138
95
139
## Examples
96
140
@@ -108,7 +152,7 @@ If you simply parse a JATS document, it will download all of the required
108
152
DTD files:
109
153
110
154
```
111
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd xml/jats/doc.xml
155
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd xml/jats/doc.xml
112
156
Performing a (DTD) validating parse of xml/jats/doc.xml
113
157
✗ Resolved: [dtd]: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthoring1.dtd
114
158
✗ Resolved: %articleauthcustom-modules.ent: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthcustom-modules1.ent (-//NLM//DTD JATS (Z39.96) Article Authoring DTD-Specific Modules v1.2 20190208//EN)
@@ -125,7 +169,7 @@ The distribution includes a local copy of the JATS DTD files and a
125
169
catalog that uses them:
126
170
127
171
```
128
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -catalog:schema/jats/catalog.xml xml/jats/doc.xml
172
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -catalog:schema/jats/catalog.xml xml/jats/doc.xml
129
173
Performing a (DTD) validating parse of xml/jats/doc.xml
130
174
✓ Resolved: [dtd]: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthoring1.dtd
131
175
as: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/jats/1.2/JATS-articleauthoring1.dtd
@@ -152,7 +196,7 @@ simplify the catalog to just a single “rewrite” entry.
152
196
There’s one in ` schema/jats/rewrite.xml ` :
153
197
154
198
```
155
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -catalog:schema/jats/rewrite.xml xml/jats/doc.xml
199
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -catalog:schema/jats/rewrite.xml xml/jats/doc.xml
156
200
✓ Resolved: [dtd]: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthoring1.dtd
157
201
as: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/jats/1.2/JATS-articleauthoring1.dtd
158
202
from: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/jats/1.2/JATS-articleauthoring1.dtd
@@ -173,7 +217,7 @@ Another way to take advantage of catalogs without having to maintain them yourse
173
217
is to use the caching feature:
174
218
175
219
```
176
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -cache xml/jats/doc.xml
220
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -cache xml/jats/doc.xml
177
221
✓ Resolved: [dtd]: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthoring1.dtd
178
222
as: https://jats.nlm.nih.gov/articleauthoring/1.2/JATS-articleauthoring1.dtd
179
223
from: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/xmlresolver-cache/data/7be3429ebd754b3978ae10454ea09856dce0c83e1d11eb2400939b9cfa9246c5.dtd
@@ -200,7 +244,7 @@ JATS directory:
200
244
```
201
245
✓ Resolved: %ent-mmlextra: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/jats/1.2/mathml/mmlextra.ent (-//W3C//ENTITIES Extra for MathML 2.0//EN)
202
246
as: mathml/mmlextra.ent
203
- from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1beta3 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/Math/DTD/mathml2/mathml/mmlextra.ent
247
+ from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/Math/DTD/mathml2/mathml/mmlextra.ent
204
248
```
205
249
206
250
The XML Resolver ships with a “data” jar file that contains a large
@@ -210,7 +254,7 @@ catalog and used to resolve the entity. If you tell the resolver not
210
254
to search for catalogs on the classpath, this won’t happen:
211
255
212
256
```
213
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -catalog:schema/jats/rewrite.xml xml/jats/doc.xml
257
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -catalog:schema/jats/rewrite.xml xml/jats/doc.xml
214
258
…
215
259
✗ Resolved: %ent-mmlextra: file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/jats/1.2/mathml/mmlextra.ent (-//W3C//ENTITIES Extra for MathML 2.0//EN)
216
260
…
@@ -228,7 +272,7 @@ servers anyway, you’ll eventually get locked out entirely.)
228
272
You can see this if you try to parse an XHTML document:
229
273
230
274
```
231
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -no-classpath-catalogs xml/xhtml/index.xhtml
275
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -no-classpath-catalogs xml/xhtml/index.xhtml
232
276
Performing a (DTD) validating parse of xml/xhtml/index.xhtml
233
277
✗ Resolved: [dtd]: https://www.w3.org/MarkUp/DTD/xhtml11.dtd (-//W3C//DTD XHTML 1.1//EN)
234
278
✗ Resolved: %xhtml-inlstyle.mod: http://www.w3.org/MarkUp/DTD/xhtml-inlstyle-1.mod (-//W3C//ELEMENTS XHTML Inline Style 1.0//EN)
@@ -243,13 +287,13 @@ Try it again, letting the resolver use the data jar, and it takes only a
243
287
fraction of a second:
244
288
245
289
```
246
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd xml/xhtml/index.xhtml
290
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd xml/xhtml/index.xhtml
247
291
✓ Resolved: [dtd]: https://www.w3.org/MarkUp/DTD/xhtml11.dtd (-//W3C//DTD XHTML 1.1//EN)
248
292
as: https://www.w3.org/MarkUp/DTD/xhtml11.dtd
249
- from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1beta3 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml11.dtd
293
+ from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml11.dtd
250
294
✓ Resolved: %xhtml-inlstyle.mod: http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-inlstyle-1.mod (-//W3C//ELEMENTS XHTML Inline Style 1.0//EN)
251
295
as: http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-inlstyle-1.mod
252
- from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1beta3 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml-inlstyle-1.mod
296
+ from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml-inlstyle-1.mod
253
297
…
254
298
```
255
299
@@ -260,8 +304,8 @@ still wanted fast access to the data jar resources, you can specify the catalog
260
304
explicitly:
261
305
262
306
```
263
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -no-classpath-catalogs \
264
- -catalog:jar:file:lib/xmlresolver-3.0.1beta3 -SNAPSHOT-data.jar!/org/xmlresolver/catalog.xml \
307
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -no-classpath-catalogs \
308
+ -catalog:jar:file:lib/xmlresolver-3.0.1 -SNAPSHOT-data.jar!/org/xmlresolver/catalog.xml \
265
309
xml/xhtml/index.xhtml
266
310
…
267
311
```
@@ -274,10 +318,10 @@ Usually, the resolver ignores catalog errors. You don’t want your production a
274
318
falling over because someone puts a typo in a catalog:
275
319
276
320
```
277
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -catalog:schema/caterror.xml xml/xhtml/index.xhtml
321
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -catalog:schema/caterror.xml xml/xhtml/index.xhtml
278
322
✓ Resolved: [dtd]: https://www.w3.org/MarkUp/DTD/xhtml11.dtd (-//W3C//DTD XHTML 1.1//EN)
279
323
as: https://www.w3.org/MarkUp/DTD/xhtml11.dtd
280
- from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1beta3 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml11.dtd
324
+ from: jar:file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/lib/xmlresolver-3.0.1 -SNAPSHOT-data.jar!/org/xmlresolver/www.w3.org/MarkUp/DTD/xhtml11.dtd
281
325
…
282
326
```
283
327
@@ -286,7 +330,7 @@ resolver to process catalogs with a validating parser. This will throw an except
286
330
if an invalid catalog is loaded:
287
331
288
332
```
289
- $ java -jar sampleapp-3.0.1beta3 .jar -dtd -validate -catalog:schema/caterror.xml xml/xhtml/index.xhtml
333
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -dtd -validate -catalog:schema/caterror.xml xml/xhtml/index.xhtml
290
334
Exception in thread "main" org.xmlresolver.exceptions.CatalogInvalidException: Catalog 'file:/Users/ndw/Projects/xmlresolver/sampleapp/build/stage/schema/caterror.xml' is invalid: attribute "systemid" not allowed here; expected attribute "id", "systemId" or "uri" or an attribute from another namespace
291
335
at org.xmlresolver.loaders.ValidatingXmlLoader.loadCatalog(ValidatingXmlLoader.java:147)
292
336
…
@@ -303,7 +347,7 @@ public identifier involved.
303
347
There’s a sample schema in RELAX NG in the distribution:
304
348
305
349
```
306
- $ java -jar sampleapp-3.0.1beta3 .jar -catalog:schema/sample/catalog.xml -rng:schema/sample/sample.rnc xml/sample/doc.xml
350
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -catalog:schema/sample/catalog.xml -rng:schema/sample/sample.rnc xml/sample/doc.xml
307
351
✗ Resolved: book (file:///Users/ndw/Projects/xmlresolver/sampleapp/build/stage/xml/sample/doc.xml)
308
352
Parse complete
309
353
✗ Resolved: schema/sample/sample.rnc
@@ -325,7 +369,7 @@ construct the call to java with an explicit classpath:
325
369
326
370
```
327
371
$ java -cp docbook/schemas-docbook-5.2b10a4.jar\
328
- :sampleapp-3.0.1beta3 .jar org.xmlresolver.example.SampleApp \
372
+ :sampleapp-3.0.1-SNAPSHOT .jar org.xmlresolver.example.SampleApp \
329
373
-rng:xml/docbook/schema.rng xml/docbook/doc.xml
330
374
✗ Resolved: article (file:///Users/ndw/Projects/xmlresolver/sampleapp/build/stage/xml/docbook/doc.xml)
331
375
Parse complete
@@ -350,7 +394,7 @@ Using a catalog for XML Schema validation is also much the same.
350
394
There’s a sample XML Schema in the distribution:
351
395
352
396
```
353
- $ java -jar sampleapp-3.0.1beta3 .jar -catalog:schema/sample/catalog.xml -xsd:schema/sample/sample.rnc xml/sample/doc.xml
397
+ $ java -jar sampleapp-3.0.1-SNAPSHOT .jar -catalog:schema/sample/catalog.xml -xsd:schema/sample/sample.rnc xml/sample/doc.xml
354
398
✗ Resolved: book (file:///Users/ndw/Projects/xmlresolver/sampleapp/build/stage/xml/sample/doc.xml)
355
399
Parse complete
356
400
✓ Resolved: http://www.w3.org/2001/XMLSchema: https://xmlresolver.org/ns/sample/blocks.xsd (http://xmlresolver.com/ns/sample)
@@ -371,7 +415,7 @@ resolve stylesheet URIs:
371
415
```
372
416
$ java -cp docbook/docbook-xslTNG-1.5.0.jar\
373
417
:docbook/schemas-docbook-5.2b10a4.jar\
374
- :sampleapp-3.0.1beta3 .jar org.xmlresolver.example.SampleApp \
418
+ :sampleapp-3.0.1-SNAPSHOT .jar org.xmlresolver.example.SampleApp \
375
419
-rng:xml/docbook/schema.rng -xsl:xml/docbook/style.xsl xml/docbook/doc.xml
376
420
✗ Resolved: article (file:///Users/ndw/Projects/xmlresolver/sampleapp/build/stage/xml/docbook/doc.xml)
377
421
Parse complete
@@ -389,17 +433,3 @@ RELAX NG validation: valid
389
433
…
390
434
Done
391
435
```
392
-
393
- ## What is the other jar file?
394
-
395
- The distribution also contains a copy of the “apps” jar from the XML
396
- Resolver. This jar contains the “CacheDetails” application that will
397
- show you what is in your XML Resolver cache, if you have one.
398
-
399
- Try:
400
-
401
- ```
402
- $ java -jar xmlresolver-3.0.1beta3-apps.jar ./resolver-cache
403
- Cache contains 73 entries
404
- …
405
- ```
0 commit comments