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

时间:2022-05-24 00:29:40

I was trying to convert a docbook document with fragmented/partial includes to pdf using Xerces 2.7.1 and Xalan 2.7.0.

我试图使用Xerces 2.7.1和Xalan 2.7.0将带有碎片/部分包含的docbook文档转换为pdf。

<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 ..>.

直到我发现为了使用部分包含,必须使用<!DOCTYPE ..>提供到模式文件的可解析路径,这才起作用。

But with Docbook 5.0 one should/has to use namespace declarations instead of DOCTYPE.

但是使用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"> 

How can I provide the docbookxi.rng to the toolchain?

如何将docbookxi.rng提供给工具链?

1 个解决方案

#1


1  

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.

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

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".

表示:“包含TestDocument.included.xml的一部分,该部分由具有类型ID属性且值为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.

在DocBook 5中,xml:id用于唯一标识符。此属性被识别为ID类型,并且不需要模式来确定其“ID-ness”(请参阅​​http://www.w3.org/TR/xml-id/)。因此,如果DocBook 5文档中有anyid属性,请将它们更改为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).

但是,您还应该确保XML解析器支持xml:id。 Xerces似乎在这里缺乏,所以它可能仍然不适合你(参见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.

如果有问题,您可以尝试使用DocBook 5 DTD(是的,即使规范模式是在RELAX NG中编写的,也有DTD)。 DTD将xml:id声明为ID类型。

#1


1  

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.

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

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".

表示:“包含TestDocument.included.xml的一部分,该部分由具有类型ID属性且值为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.

在DocBook 5中,xml:id用于唯一标识符。此属性被识别为ID类型,并且不需要模式来确定其“ID-ness”(请参阅​​http://www.w3.org/TR/xml-id/)。因此,如果DocBook 5文档中有anyid属性,请将它们更改为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).

但是,您还应该确保XML解析器支持xml:id。 Xerces似乎在这里缺乏,所以它可能仍然不适合你(参见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.

如果有问题,您可以尝试使用DocBook 5 DTD(是的,即使规范模式是在RELAX NG中编写的,也有DTD)。 DTD将xml:id声明为ID类型。