将 Docbook 5.0(包含部分内容)转换为 PDF

发布于 2024-12-22 00:55:51 字数 552 浏览 2 评论 0原文

我试图使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

做个ˇ局外人 2024-12-29 00:55:51

在这种情况下,没有办法“向工具链提供 docbookxi.rng”来提供帮助。甚至没有一种标准方法可以将 XML 文档与 RELAX NG 模式关联起来。 xmlns="http://docbook.org/ns/docbook" 命名空间声明将文档标识为 DocBook 5(与 version 属性一起),但它并不说出有关架构位置的任何内容。

像这样的一行,

<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>

意思是:“包含 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 the version attribute), but it does not say anything about the location of the schema.

A line like this one,

<xi:include href="./TestDocument.included.xml" xpointer="Section2"/>

means: "include the portion of TestDocument.included.xml that is identified by the element that has an attribute of type ID with a value of Section2".

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 to xml: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文