XSL-FO:在表项上强制换行 [英] XSL-FO: Force Wrap on Table Entries

查看:106
本文介绍了XSL-FO:在表项上强制换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将我的modspec发布到pdf(XSL-FO)时遇到问题.我的表有问题,单元格的内容将其列溢出到下一个.如何在文本上强制换行,以代替创建新行?

I'm having an issue where when I publish my modspecs to pdf (XSL-FO). My tables are having issues, where the content of a cell will overflow its column into the next one. How do I force a break on the text so that a new line is created instead?

由于表项是通过编程输入的,因此我无法手动插入零空格字符.我正在寻找一种简单的解决方案,只需将其添加到docbook_pdf.xsl中即可(以xsl:param或xsl:attribute的形式)

I can't manually insert zero-space characters since the table entries are programmatically entered. I'm looking for a simple solution that I can just simply add to docbook_pdf.xsl (either as a xsl:param or xsl:attribute)

这是我目前所在的位置:

Here is where I'm at currently:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:import href="urn:docbkx:stylesheet"/>
...(the beginning of my stylesheet for pdf generation, e.g. header and footer content stuff)
<xsl:template match="text()">
    <xsl:call-template name="intersperse-with-zero-spaces">
        <xsl:with-param name="str" select="."/>
    </xsl:call-template>
</xsl:template>
<xsl:template name="intersperse-with-zero-spaces">
    <xsl:param name="str"/>
    <xsl:variable name="spacechars">
        &#x9;&#xA;
        &#x2000;&#x2001;&#x2002;&#x2003;&#x2004;&#x2005;
        &#x2006;&#x2007;&#x2008;&#x2009;&#x200A;&#x200B;
    </xsl:variable>

    <xsl:if test="string-length($str) &gt; 0">
        <xsl:variable name="c1" select="substring($str, 1, 1)"/>
        <xsl:variable name="c2" select="substring($str, 2, 1)"/>

        <xsl:value-of select="$c1"/>
        <xsl:if test="$c2 != '' and
            not(contains($spacechars, $c1) or
            contains($spacechars, $c2))">
            <xsl:text>&#x200B;</xsl:text>
        </xsl:if>

        <xsl:call-template name="intersperse-with-zero-spaces">
            <xsl:with-param name="str" select="substring($str, 2)"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>

</xsl:stylesheet>

由此,长单词在表格单元格中成功分解!不幸的是,副作用是其他地方的普通文本(例如在X色下)现在将单词分解了,使它们出现在单独的行上.有没有办法将上述过程隔离为表格?

With this, the long words are successfully broken up in the table cells! Unfortunately, the side effect is that normal text elsewhere (like in a under sextion X) now breaks up words so that they appear on seperate lines. Is there a way to isolate the above process to just tables?

推荐答案

长话大说,尝试插入

In the long words, try inserting a zero-width space character between the characters where a break is allowed.

以下是讨论该问题的各种方法的邮件列表线程: http://www.stylusstudio.com/xsllist/200201/post80920.html .

Here is a mailing list thread where various approaches to the problem are discussed: http://www.stylusstudio.com/xsllist/200201/post80920.html.

SourceForge DocBook样式表包含一个用于在FO输出中分解长URL的模板;参见 http://www.sagehill.net/docbookxsl/Ulinks.html#BreakLongUrls.模板(hyphenate-url)位于 xref.xsl .

The SourceForge DocBook stylesheets includes a template for breaking up long URLs in FO output; see http://www.sagehill.net/docbookxsl/Ulinks.html#BreakLongUrls. The template (hyphenate-url) is in xref.xsl.

这篇关于XSL-FO:在表项上强制换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆