ZIP files as XML Catalogs
Schemas and other resources are often distributed in ZIP files. Now you can just point the resolver at them.
As I proposed a couple of weeks ago, I’ve implemented the feature whereby you can just put ZIP files on the catalog path.
TL;DR, you can try this out with the 3.1.0-SNAPSHOT release of XML Resolver:
- Create a ZIP file containing the resources you want to resolve.
- Add a catalog to it that resolves URIs for those resources relative to the catalog.
- Add the ZIP file to the catalog path.
ZIP files seem to come in two flavors, one that unzip files into the current directory:
$ unzip -v sample
Archive: sample.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
1481 Defl:N 398 73% 07-11-2021 10:02 28c9c5bd sample.xsd
266 Defl:N 155 42% 07-11-2021 10:02 b499b6f3 blocks.rnc
1129 Defl:N 273 76% 07-28-2021 17:29 22734814 catalog.xml
…
417 Defl:N 188 55% 07-11-2021 10:02 0d156a81 blocks.dtd
-------- ------- --- -------
18972 5994 68% 13 files
and ones that unzip files into a common subdirectory:
$ unzip -v dir-sample.zip
Archive: dir-sample.zip
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
0 Stored 0 0% 08-10-2021 16:27 00000000 directory-x.y/
1481 Defl:N 398 73% 07-11-2021 10:02 28c9c5bd directory-x.y/sample.xsd
266 Defl:N 155 42% 07-11-2021 10:02 b499b6f3 directory-x.y/blocks.rnc
1129 Defl:N 273 76% 07-28-2021 17:29 22734814 directory-x.y/catalog.xml
…
417 Defl:N 188 55% 07-11-2021 10:02 0d156a81 directory-x.y/blocks.dtd
-------- ------- --- -------
18972 5994 68% 14 files
If every entry in the ZIP file begins with the same directory name (e.g., directory-x.y/
), then
the resolver looks for directory-x.y/org/xmlresolver/catalog.xml
and
directory-x.y/catalog.xml
. If it finds both, it uses the former.
If there are no leading directories, or if there are different leading
directories, or if only some files are in directories, then the
resolver looks for org/xmlresolver/catalog.xml
and catalog.xml
. Once
again, if it finds both, it uses the former.
Feedback welcome.