Skip to content

Commit

Permalink
Merge pull request #521 from ndw/iss-504
Browse files Browse the repository at this point in the history
Rework Java initialization to support the -catalog option
  • Loading branch information
ndw authored Oct 9, 2024
2 parents 7688aa3 + 8b29318 commit 455b502
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/bin/docbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def __init__(self, args):

self._parse_args(args)

self.catalogs.append(f"{self.root}/xslt/catalog.xml")
if not self.stylesheet:
self.stylesheet = f"-xsl:{self.root}/xslt/docbook.xsl"
self._app_args.append(self.stylesheet)
Expand Down Expand Up @@ -577,8 +576,10 @@ def run(self):
"""Run the process."""
cp = self.classpath()
args = self.args()
jopt = ["-Dxml.catalog.files=" + ";".join(self.catalogs)]
jopt = jopt + self.config.get("java-options", [])
if self.catalogs:
args.append("-catalog:" + ";".join(self.catalogs))

jopt = self.config.get("java-options", [])
if self.debug:
print(self._java)
for item in jopt:
Expand Down
7 changes: 7 additions & 0 deletions src/guide/xml/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ development continues.</para>
“<code>portrait</code>” in their <att>class</att> attribute. At present, this has no
effect in the browser presentation.</para>
</listitem>
<listitem>
<para>Reworked Java initialization;
fixed <link xlink:href="https://github.com/docbook/xslTNG/issues/504">#504</link>.
This change is a consequence of how Saxon initializes the XML Resolver.
</para>
</listitem>

</itemizedlist>
</section>

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/org/docbook/xsltng/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class Main extends Transform {
Vector<String> userArgs = new Vector<>();
private Vector<String> userCatalogFiles = new Vector<> ();
private final Vector<String> userCatalogFiles = new Vector<> ();
private boolean userStylesheet = false;
private boolean uriResolver = false;
private boolean sourceReader = false;
Expand Down Expand Up @@ -60,8 +60,8 @@ public void run() {
catBuilder.append(";");
catBuilder.append(cat);
}
userArgs.add("-catalog:" + catBuilder);

System.setProperty("xml.catalog.files", catBuilder.toString());
userArgs.add("-init:org.docbook.xsltng.extensions.Register");
if (!userStylesheet) {
userArgs.add("-xsl:https://cdn.docbook.org/release/xsltng/current/xslt/docbook.xsl");
Expand All @@ -71,7 +71,6 @@ public void run() {
userArgs.toArray(args);

if (logger.getFlag("java-args")) {
logger.debug("java-args", "xml.catalog.files=" + System.getProperty("xml.catalog.files"));
for (String arg : args) {
logger.debug("java-args", arg);
}
Expand Down

0 comments on commit 455b502

Please sign in to comment.