将 Docbook 5.0(包含部分内容)转换为 PDF
我试图使用 Xerces 2.7.1 和 Xalan 2.7.0 将带有碎片/部分包含的 docbook 文档转换为 pdf。
<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>
直到我发现为了使用部分包含,必须使用 提供模式文件的可解析路径,这才起作用。
但对于 Docbook 5.0,人们应该/必须使用名称空间声明而不是 DOCTYPE。
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
xml:lang="de" version="5.0" status="DRAFT" security="confidential">
如何向工具链提供 docbookxi.rng?
I was trying to convert a docbook document with fragmented/partial includes to pdf using Xerces 2.7.1 and Xalan 2.7.0.
<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>
This did not work until I figured out that in order to use partial includes one has to provide a resolveable path to the schemafile using <!DOCTYPE ..>
.
But with Docbook 5.0 one should/has to use namespace declarations instead of DOCTYPE.
<?xml version="1.0" encoding="UTF-8"?>
<article xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude"
xml:lang="de" version="5.0" status="DRAFT" security="confidential">
How can I provide the docbookxi.rng to the toolchain?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,没有办法“向工具链提供 docbookxi.rng”来提供帮助。甚至没有一种标准方法可以将 XML 文档与 RELAX NG 模式关联起来。
xmlns="http://docbook.org/ns/docbook"
命名空间声明将文档标识为 DocBook 5(与version
属性一起),但它并不说出有关架构位置的任何内容。像这样的一行,
意思是:“包含
TestDocument.included.xml
的部分,该部分由具有 ID 类型属性且值为Section2
的元素标识”。在 DocBook 5 中,
xml:id
用于唯一标识符。该属性被识别为 ID 类型,并且不需要架构来确定其“ID 性”(请参阅 http://www.w3.org/TR/xml-id/)。因此,如果 DocBook 5 文档中有任何id
属性,请将它们更改为xml:id
。但是,您还应该确保 XML 解析器支持
xml:id
。这里似乎缺少 Xerces,因此它可能仍然不适合您(请参阅 https:// issues.apache.org/jira/browse/XERCESJ-1113)。如果出现问题,您可以尝试使用 DocBook 5 DTD (是的,即使规范模式是用 RELAX NG 编写的,也存在 DTD)。该 DTD 将
xml:id
声明为 ID 类型。There is no way to "provide the docbookxi.rng to the toolchain" that would help in this case. There isn't even a standard way to associate an XML document with a RELAX NG schema. The
xmlns="http://docbook.org/ns/docbook"
namespace declaration identifies the document as DocBook 5 (together with theversion
attribute), but it does not say anything about the location of the schema.A line like this one,
means: "include the portion of
TestDocument.included.xml
that is identified by the element that has an attribute of type ID with a value ofSection2
".In DocBook 5,
xml:id
is used for unique identifiers. This attribute is recognized as being of type ID, and there is no need for a schema to determine its "ID-ness" (see http://www.w3.org/TR/xml-id/). So if you have anyid
attributes in your DocBook 5 documents, change them toxml:id
.Howewer, you should also make sure that the XML parser supports
xml:id
. Xerces seems to be lacking here, so it might still not work for you (see https://issues.apache.org/jira/browse/XERCESJ-1113).If there are problems, you could try to use the DocBook 5 DTD (yes, there is a DTD even though the normative schema is written in RELAX NG). That DTD declares
xml:id
to be of type ID.