Catalog file ignored when using the jar file?
fsteimke opened this issue · 5 comments
Hi,
i have a XSLT Stylesheet as customization layer for xslTNG. It imports the xslTNG/xslt/print.xsl
stylesheet and sets some parameters.
The import
uses an URL which does not exist in reality, but is defined in a catalog file:
<xsl:import href="http://www.xoev.de/xsltng/print.xsl"/>
<uri name="http://www.xoev.de/xsltng/print.xsl"
uri="../../docbook-xslTNG-2.2.0/xslt/print.xsl"/>
It works fine within Oxygen. It does not, however, outside Oxygen when i use the JAR file (section 2.1 in the reference manual) with the -catalog
parameter. Even when i add the uri/name definition in the catalag file which is part of the xslTNG Stylesheets in xslt/catalog.xml
it does not work. My impression is that catalog files are ignored completely when the JAR file is used.
Or did i miss something?
Thanks in advance,
Frank
Just my 2 cents here. I have been struggling with the same problem too. However, I am not using the jar file directly, but the docbook Python wrapper. I am pretty sure that the Python script produces wrong parameters. The Python script produces a command like this one:
/usr/bin/java \
-Dxml.catalog.files="/var/www/html/config/catalog.xml;/usr/local/docbook/xslt/catalog.xml" \
-cp /usr/local/docbook/libs/docbook-xslTNG-2.2.1.jar \
net.sf.saxon.Transform \
-xsl:https://resources.paligo.net/xslt/print.xsl \
article.xml \
-init:org.docbook.xsltng.extensions.Register
It seems that the parameter xml.catalog.files is not picked up by Saxon. If I specify the catalogs like so (as a Saxon parameter):
/usr/bin/java \
-cp /usr/local/docbook/libs/docbook-xslTNG-2.2.1.jar \
net.sf.saxon.Transform \
-catalog:"/var/www/html/config/catalog.xml;/usr/local/docbook/xslt/catalog.xml" \
-xsl:https://resources.paligo.net/xslt/print.xsl \
article.xml \
-init:org.docbook.xsltng.extensions.Register
The stylesheet is resolved to the local file and I am getting output.
Sorry. I'll try to look at this issue next.
Right. The problem here is that when Saxon switched to using the XML Resolver internally, it carefully and deliberately made sure that none of the default catalog loading behavior of XML Resolver (such as loading catalogs specified in system properties) would cause default catalogs to be loaded. This preserved backwards compatibiltiy for existing users. But it sure can be a PITA.
The DocBook xslTNG Java code attempts to set default catalog(s) with the system property. The only workaround, I think, is to pass a single -catalog:
option to Saxon. Slightly less flexible, but you can always construct a single catalog that includes others if you want to use multiple catalogs, so not an insurmountable inconvenience.
Maybe this could work (I'm not super familiar in Python...)
--- docbook 2024-09-27 14:44:56
+++ docbook-fixed 2024-10-09 19:43:27
@@ -93,6 +93,9 @@
if not self.stylesheet:
self.stylesheet = f"-xsl:{self.root}/xslt/docbook.xsl"
self._app_args.append(self.stylesheet)
+
+ catalogs = ";".join(self.catalogs)
+ self._app_args.append(f"-catalog:{catalogs}")
try:
with open(self.config_file, "r") as depfile:
@@ -581,7 +584,7 @@
"""Run the process."""
cp = self.classpath()
args = self.args()
- jopt = ["-Dxml.catalog.files=" + ";".join(self.catalogs)]
+ jopt = []
jopt = jopt + self.config.get("java-options", [])
if self.debug:
print(self._java)
I did something like that. PR should be merged in a few minutes. Thanks!