我使用 docbook 生成文档。主文档的结构是模块化的,使用 xinclude 用于不同的模块。
我的问题是通过xinclude包含在主文档中的逐字元素(具有显着空白的元素)。
如果我直接在主文档中使用 literallayout ,则输出与预期的一样:保留空白。
我想使用一个包含文件的文件,其中包含一个带有literallayout元素的部分。 如果我生成包含文件的文档,则输出将去除其空格。
有人可以告诉我如何在逐字元素(如literallayout或programlisting)中保留空白吗?
File1.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<section id="someid">
<title>section title</title>
<para>
<literallayout>
This shall show a small picure with '0':
0
000
00000
</literallayout>
</para>
</section>
如果我将其生成为独立文档,则输出是预期的:
0
000
00000
如果我按如下方式使用它: File2.xml:
<?xml version="1.0" encoding="ISO-8859-15"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
<book>
<bookinfo>
...minimum input here
</bookinfo>
<chapter id="First_Chapter">
<title>Introduction</title>
<section id="First_Section">
<title>literallayout and programlisting in the main xml file</title>
<para><literallayout>This should look like a triangle built out of the character '0'
0
000
00000
</para>
</section>
<xi:include href="File1.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
</chapter>
</book>
如果我生成此文档,则第一部分将如预期的那样(如金字塔形)
但是在xinclude包含的部分中,所有'0'都在一行0 000 00000上输出。
答案 0 :(得分:0)
我认为自己找到了解决问题的方法:
如果所包含的literallayout元素添加了属性 xml:space="preserve"
,应该会有所帮助。这应该是默认设置,但是xinclude似乎以某种方式“丢失”或“替换”它。