Should an XML catalog be able to resolve modules?

267 Views Asked by At

I am trying to run an XSL transform on XML with a doctype like this:

<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1d3 20150301//EN" "http://jats.nlm.nih.gov/publishing/1.1d3/JATS-journalpublishing1.dtd">

I am using Java 11 around the processor:

Source s = getXsl(src, bibSources);

System.setProperty("javax.xml.accessExternalDTD", "all");
System.setProperty("javax.xml.accessExternalSchema", "all");
System.setProperty("javax.xml.catalog.files", xmlCatalog);

System.setProperty(CatalogFeatures.Feature.RESOLVE.getPropertyName(), "strict");

TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl();
factory.setFeature("http://saxon.sf.net/feature/suppressXsltNamespaceCheck",true);
StringWriter writer = new StringWriter();
StreamResult streamResult = new StreamResult(writer);

Transformer t = factory.newTransformer(s);
Source xml = new StreamSource(zip.getInputStream(entry));
t.transform(xml,streamResult);

The error I get upon running the transform is like this:

Error on line 333 column 31 of JATS-journalpublishing1.dtd:
  SXXP0003: Error reported by XML parser: JAXP00090001: The CatalogResolver is enabled with
  the catalog "catalog.xml", but a CatalogException is returned.: JAXP09040001: No match
  found for publicId '-//NLM//DTD JATS (Z39.96) Journal Publishing DTD-Specific Modules
  v1.1d3 20150301//EN' and systemId 'JATS-journalpubcustom-modules1.ent'.

The catalog is being accessed, but it seems not to be able to resolve modules the DTD depends on. Is this normal, or am I setting the XML properties incorrectly in Java?

EDIT:

XML catalog has an entry for the dtd:

<public publicId="-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1d3 20150301//EN" uri="http://ecswebqa02:8080/xml-catalog/dtd/jatsDTD/JATS-Publishing-1-1d3-MathML2-DTD/JATS-journalpublishing1.dtd"/>

The catalog does not have an entry for the module, though the module is located adjacent to the local copy of the dtd:

http://ecswebqa02:8080/xml-catalog/dtd/jatsDTD/JATS-Publishing-1-1d3-MathML2-DTD/JATS-journalpubcustom-modules1.ent
1

There are 1 best solutions below

1
On

I'd expect the resolver to do the right thing if the relative URIs of the entities are correct. If you're using the Apache commons resolver, it's possible to get more detailed processing messages by turning up the "xml.catalog.verbosity" setting, http://xerces.apache.org/xml-commons/components/resolver/resolver-article.html

You might also try the https://xmlresolver.org/ resolver which is more recent.