I think the catalog resolver is functioning properly, but you can question
the behavior of xmllint.
The XML Catalog specification describes the steps for finding and returning
a matching entry in the catalog.
http://www.oasis-open.org/committees/entity/spec-2001-08-06.html#s.uri.res
It doesn't describe what the program does in response to the value returned
by the resolver. In your case, the xmllint catalog resolver does find a
match in your catalog file. When xmllint tries to use that value, however,
it finds that the local file it points to doesn't exist. It does not
restart the catalog resolver to find another entry that does work. Nor does
it fall back to the original system id. It seems the xmllint program gives
up once it finds a match, not when it finds a file it can open.
One could argue that if xmllint can't open the resource returned by the
catalog, then xmllint should continue trying other alternatives, such as the
original URI or another catalog try. From another point of view, since it
does find a match in the catalog, then that is the intended resource. It is
an error that the designated resource it not usable, and xmllint takes that
error as fatal. I suspect the authors of xmllint would blame your catalog,
not the program, but you might take it up with them.
As another data point, I tried Saxon which uses the Java catalog resolver
(resolver.jar). When Saxon encounters the bad catalog entry, it seems to
fall back to the original URI, which is what you want.
Bob Stayton
Sagehill Enterprises
[EMAIL PROTECTED]
----- Original Message -----
From: "John Brown" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, March 21, 2008 6:26 AM
Subject: [docbook-apps] Re: Fall back to network DTD if local one not found
Thomas Schraitle <tom_schr <at> web.de> writes:
Hi,
On Donnerstag, 20. März 2008, John Brown wrote:
> [...]
>
> I can then 'set SGML_CATALOG_FILES=catalog.xml'
<snip>
However, in your case, you seem to use *XML* catalog, so
SGML_CATALOG_FILES is wrong. Did you try it with the env variable
XML_CATALOG_FILES?
I did not, but these are the results:
<!-- using bogus catalog file -->
C:\Book>set XML_CATALOG_FILES=non-existent.xml
C:\Book>set | find "CATALOG"
XML_CATALOG_FILES=non-existent.xml
Fri Mar 21 07:27:28 2008
C:\Book>xmllint --valid --noout book2.xml
Fri Mar 21 07:27:37 2008
<!-- Succeeded after 9 seconds - apparently network DTD used -->
<!-- using genuine catalog file -->
C:\Book>set XML_CATALOG_FILES=catalog.xml
C:\Book>set | find "CATALOG"
XML_CATALOG_FILES=catalog.xml
Fri Mar 21 07:27:37 2008
C:\Book>xmllint --valid --noout book2.xml
Fri Mar 21 07:27:38 2008
<!-- Succeeded after 1 second - apparently local DTD used -->
<!-- hiding local DTD; hoping to fall back to network DTD -->
C:\Book>cd \MSYS\share\xml\docbook\4.5
C:\MSYS\share\xml\docbook\4.5>move docbookx.dtd docbookx.dtd2
C:\MSYS\share\xml\docbook\4.5>cd \Book
Fri Mar 21 07:27:38 2008
C:\Book>xmllint --valid --noout book2.xml
book2.xml:3: warning: failed to load external entity
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
^
book2.xml:5: validity error : Validation failed: no DTD found !
<book lang="en">
Fri Mar 21 07:27:38 2008
<!-- failed after 1 second - did not try to use the network DTD -->
I haven't look much in the details, but maybe debug your *XML* catalog
first. You can do this with xmlcatalog (one line):
xmlcatalog PATH_TO_YOUR_XML_CATALOG \
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"
The above line outputs the path to your local DTD. If you get "No entry
for ..." then you should look into your XML catalog again.
This gives the same result as the xmllint commands above. It finds the
path to the local DTD. My problem is that, if I have followed the
instructions in Bob Stayton's tutorial correctly, then xmllint and friends
should try to fetch the DTD from the network, but they just give up.
You can also debug the catalog processing with the environment variable
XML_DEBUG_CATALOGS. In this case, xmllint is a bit more verbose. :)
After setting XML_DEBUG_CATALOG:
C:\Book>xmllint --valid --noout book2.xml
Resolve: pubID -//OASIS//DTD DocBook XML V4.5//EN sysID
http://www.oasis-open.or
g/docbook/xml/4.5/docbookx.dtd
880 Parsing catalog catalog.xml
catalog.xml added to file hash
Found system match http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd,
using
c:/msys/share/xml/docbook/4.5/docbookx.dtd
Resolve URI c:/msys/share/xml/docbook/4.5/docbookx.dtd
book2.xml:3: warning: failed to load external entity
"http://www.oasis-open.org/
docbook/xml/4.5/docbookx.dtd"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
^
book2.xml:5: validity error : Validation failed: no DTD found !
<book lang="en">
^
Catalogs cleanup
Free catalog entry -//OASIS//DTD DocBook XML V4.5//EN
Free catalog entry DocbookDTD
Free catalog entry http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd
<!-- long list of catalog entries snipped -->
Free catalog entry
My XML file header:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
From the above output, it maps http://www.osais-open.org/.../docbookx.dtd
to c:/msys/share/xml/docbook/4.5/docbookx.dtd. This file no longer exists,
so it reports that it cannot load the external entity
http://www.osais-open.org/.../docbookx.dtd. However, it does not try to
use the literal value http://www.osais-open.org/.../docbookx.dtd.
C:\Book>
Hope these ideas help a bit,
Tom
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]