如何强制换行表条目 [英] How to force wrap on table entries

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

问题描述

我在将 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.

这篇关于如何强制换行表条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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