Wednesday, March 17, 2010

Failure reading file:///bla.xml: docbookV4.5/docbookx.dtd (No such file or directory)

I was trying to generate PDF from my input docbook file trying to use Saxon. I had used xsltproc without any issue so far until today.

Here is the issue, by default serna generate the following header:

<?xml version='1.0' encoding='UTF-8'?>
<!-- This document was created with Syntext Serna Free. -->
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "docbookV4.5/docbookx.dtd" []>

So in order to find this docbookx.dtd file, you have two options either use the system identifier or the public identifier. Apparently on debian xsltproc is properly setup so as to take the public identifier, while saxon + resolver is setup to use the system one.

Ref:
http://patch-tracker.debian.org/patch/debianonly/view/libxml-commons-resolver1.1-java/1.2-5

--- libxml-commons-resolver1.1-java-1.2.orig/debian/CatalogManager.properties
+++ libxml-commons-resolver1.1-java-1.2/debian/CatalogManager.properties
@@ -0,0 +1,61 @@
+########################################################################
+# CatalogManager provides an interface to the catalog properties.
+# Properties can come from two places: from system properties or
+# from a CatalogManager.properties file. This class provides a
+# transparent interface to both, with system properties preferred
+# over property file values.
+
+#######################################################################
+# Catalog Files:
+# The semicolon-delimited list of catalog files.
+# Example: catalogs=./xcatalog;/share/doctypes/catalog
+
+catalogs=/etc/xml/catalog
+
+#######################################################################
+# Relative Catalogs:
+# If false, relative catalog URIs are made absolute with respect to the
+# base URI of the CatalogManager.properties file. This setting only
+# applies to catalog URIs obtained from the catalogs property in the
+# CatalogManager.properties file
+# Example: relative-catalogs = [yes|no]
+
+relative-catalogs=yes
+
+#######################################################################
+# Verbosity:
+# If non-zero, the Catalog classes will print informative and debugging
+# messages. The higher the number, the more messages.
+# Example: verbosity = [0..99]
+
+verbosity=0
+
+#######################################################################
+# Prefer:
+# Which identifier is preferred, "public" or "system"?
+# Example: xml.catalog.prefer = [public|system]
+
+prefer=system
+


I think this is a better solution to use public identifier so I change my settings. But technically an easier solution is simply to use proper public AND system identifier:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">

No comments: