xml - XML 目录应该能够解析模块吗?
问题描述
我正在尝试使用这样的文档类型在 XML 上运行 XSL 转换:
<!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">
我在处理器周围使用 Java 11:
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);
我在运行转换时遇到的错误是这样的:
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'.
正在访问目录,但似乎无法解析 DTD 所依赖的模块。这是正常的,还是我在 Java 中错误地设置了 XML 属性?
编辑:
XML 目录有一个 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"/>
目录没有该模块的条目,尽管该模块位于 dtd 的本地副本附近:
http://ecswebqa02:8080/xml-catalog/dtd/jatsDTD/JATS-Publishing-1-1d3-MathML2-DTD/JATS-journalpubcustom-modules1.ent
解决方案
如果实体的相对 URI 是正确的,我希望解析器做正确的事情。如果您使用的是 Apache 公共解析器,则可以通过打开“xml.catalog.verbosity”设置来获取更详细的处理消息, http: //xerces.apache.org/xml-commons/components/resolver/resolver -article.html
您也可以尝试更新的https://xmlresolver.org/解析器。
推荐阅读
- python - 格式化 SecondaryAxis 刻度标签 Matplotlib
- c - 消息队列中的无效参数和标识符已删除错误
- azure - 我可以使用更改源、cosmos db 和 azure 函数来跟踪意外缺少更改吗?
- admob - SwiftUI 中的 Google AdMob 插页式广告
- java - 我需要一些帮助来使用 java 开始这个离散数学。我完全不知所措
- spring-boot - 在 Mac 上使用 Jhipster 和 maven 构建(并成功运行)一个 Jar,但无法在 Ubuntu 上运行
- python - 如何最小化python3.7应用程序docker镜像
- python - 无法捕获窗口标题python
- postgresql - jOOQ 生成成功后总是抱怨“没有找到适合createField的方法”
- c# - 实体框架扩展:带有更新语句的 BulkMerge