首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >XML目录应该能够解析模块吗?

XML目录应该能够解析模块吗?
EN

Stack Overflow用户
提问于 2020-09-29 03:03:25
回答 1查看 110关注 0票数 0

我正在尝试对具有如下doctype的XML运行XSL转换:

代码语言:javascript
复制
<!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:

代码语言:javascript
复制
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);

我在运行转换时得到的错误如下:

代码语言:javascript
复制
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条目:

代码语言:javascript
复制
<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的本地副本附近,但该目录没有该模块的条目:

代码语言:javascript
复制
http://ecswebqa02:8080/xml-catalog/dtd/jatsDTD/JATS-Publishing-1-1d3-MathML2-DTD/JATS-journalpubcustom-modules1.ent
EN

回答 1

Stack Overflow用户

发布于 2020-09-29 14:21:25

如果实体的相对URI是正确的,我希望解析器做正确的事情。如果您正在使用Apache commons解析器,可以通过打开"xml.catalog.verbosity“设置http://xerces.apache.org/xml-commons/components/resolver/resolver-article.html来获得更详细的消息处理信息

您也可以尝试使用较新的https://xmlresolver.org/解析器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64108140

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档