如何丢弃在eXist-db应用程序内生成的XSL-FO中的换行符?

时间:2017-05-23 08:36:03

标签: xslt xsl-fo exist-db

我对XSL-FO中关于空白处理的一些技巧感到有些困惑。

示例(段落内):

<hi rendition="simple:italic"> jeden její prvek i(</hi>
<hi rendition="simple:bold-italic">E</hi>
<hi rendition="simple:italic">)</hi>

段落上使用的属性(所有hi的父级):

<xsl:attribute name="linefeed-treatment">ignore</xsl:attribute>
<xsl:attribute name="white-space-treatment">preserve</xsl:attribute>
<xsl:attribute name="white-space-collapse">true</xsl:attribute>

...生产

jedenjejíveveki( E

格式化很好,所有斜体和粗体斜体都是正确的。问题是括号内的那些空格。

我不知道问题是否可能是由eXist-db处理单独的元素引起的。每当我在eXide中打开文件时,它会自动断开单独行上的所有内联元素。如果在向FOP提供文件期间出现这种情况,并且如果换行符与U + 000A不同,我想我会丢失。

更新我

我的应用程序内部的典型文档处理相当复杂,但当我以这种方式测试时,结果是相同的:

  1. 将带有doc()函数的doc加载到变量中;
  2. 通过样式表传递变量并将其存储到另一个变量中;
  3. 将第二个变量传递给xslfo:render()函数;
  4. 直接传输pdf结果或将其保存到数据库中。
  5. 可以将中间产品存储为test.fo,但在其中不明显为什么存在空格问题。我想这个问题对于连续的内联元素来说是典型的。

    更新II

    如果我尝试使用此fo生成pdf,则结果符合预期:

    <fo:root xml:lang="en" xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master page-height="297mm" page-width="210mm" margin-top="10mm" margin-left="20mm" margin-right="20mm"
          margin-bottom="10mm" master-name="PageMaster1">
          <fo:region-body margin-top="0mm" margin-left="0mm" margin-right="0mm" margin-bottom="10mm" />
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="PageMaster1">
        <fo:flow flow-name="xsl-region-body">
          <fo:block text-align="justify">
            <fo:block>Lorem ipsum dolor 
              <fo:inline font-style="italic">test(</fo:inline>
              <fo:inline font-weight="bold">E</fo:inline>
              <fo:inline font-style="italic">)end</fo:inline>
              next lorem.</fo:block>
          </fo:block>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
    

    如果我尝试存储测试fo文件,则问题部分似乎如此:

    <fo:inline font-style="italic" color="#91046e" language="cs">jeden její prvek i(</fo:inline> <fo:inline font-weight="bold" font-style="italic" color="#5f3cb6" language="cs">E</fo:inline> <fo:inline font-style="italic" color="#91046e" language="cs">)</fo:inline>
    

    因此,似乎问题可能出现在我的样式表中。

    例如,我的斜体模板:

    <xsl:template match="tei:hi[@rendition='simple:italic']">
        <fo:inline xsl:use-attribute-sets="italic">
            <xsl:apply-templates/>
        </fo:inline>
    </xsl:template>
    

    我目前没有使用特殊的空白或换行处理。我尝试了它没有效果。我也尝试过序列化,没有效果。 (我特别用它来生成较小的epub文件,但这里的fo输出保持不变。它猜测序列化选项会被Saxon覆盖,无论打印多么漂亮,它都只是按原样获取文件。)

1 个答案:

答案 0 :(得分:1)

在'编辑&gt;下首选项',您可以尝试调整'软包装'和'显示不可见'首选项,看看是否可以确定eXide是否添加空格。

您可以尝试设置'indent'和'suppress-indent'参数。请参阅https://www.w3.org/TR/xquery-31/#id-serializationhttps://www.w3.org/TR/xslt-xquery-serialization-31/#xml-indent

您可以尝试使用http://exist-db.org/xquery/file模块中的函数(请参阅http://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/file&location=java:org.exist.xquery.modules.file.FileModule&details=true)将eXist处理的FO写入日志或文件中(尽可能查看)是否eXist正在添加空格。