Xml XSL-FO在表格单元格中包装长文本

Xml XSL-FO在表格单元格中包装长文本,xml,oracle-apex,word-wrap,xsl-fo,Xml,Oracle Apex,Word Wrap,Xsl Fo,我使用XSL-FO作为报告查询模板,将在Oracle APEX中运行时生成的表导出为pdf。不幸的是,单元格内的长单词没有被包装,它们与相邻单元格重叠,这使得报告非常难看和无用。如何解决这个问题? 注:我知道这个问题已经被问过很多次了。我的问题是,我找到的所有解决方案似乎都不起作用。 特别是,我正在实施我在这里发现的内容: 有了这个解决方案,一切都不会发生。我尝试在模板中插入红色文本的命令,以检查它是否有效,但答案是否定的。您可以看到,我也尝试使用连字号和换行选项,如问题的其他答案所示,但没有

我使用XSL-FO作为报告查询模板,将在Oracle APEX中运行时生成的表导出为pdf。不幸的是,单元格内的长单词没有被包装,它们与相邻单元格重叠,这使得报告非常难看和无用。如何解决这个问题? 注:我知道这个问题已经被问过很多次了。我的问题是,我找到的所有解决方案似乎都不起作用。 特别是,我正在实施我在这里发现的内容:

有了这个解决方案,一切都不会发生。我尝试在模板中插入红色文本的命令,以检查它是否有效,但答案是否定的。您可以看到,我也尝试使用连字号和换行选项,如问题的其他答案所示,但没有成功。我怎样才能解决这个问题?插入零空格的模板是否放置在正确的位置

这是我的代码:

 <xsl:stylesheet xmlns:fox="http://xml.apache.org/fop/extensions" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:saxon="http://icl.com/saxon" extension-element-prefixes="saxon" >
    <xsl:variable name="_XDOFOPOS" select="''"/>
    <xsl:variable name="_XDOFOPOS2" select="number(1)"/>
    <xsl:variable name="_XDOFOTOTAL" select="number(1)"/>
    <xsl:variable name="_XDOFOOSTOTAL" select="number(0)"/>

    <!-- VARIOUS OTHER ATTRIBUTES HERE  -->

    <xsl:attribute-set name="cell">
        <xsl:attribute name="background-color">#BODY_BG_COLOR#</xsl:attribute>     
        <xsl:attribute name="color">#BODY_FONT_COLOR#</xsl:attribute>
        <xsl:attribute name="padding-start">5.15pt</xsl:attribute>
        <xsl:attribute name="vertical-align">top</xsl:attribute>
        <xsl:attribute name="padding-top">0.0pt</xsl:attribute>
        <xsl:attribute name="padding-end">5.15pt</xsl:attribute>
        <xsl:attribute name="number-columns-spanned">1</xsl:attribute>
        <xsl:attribute name="height">0.0pt</xsl:attribute>
        <xsl:attribute name="padding-bottom">0.0pt</xsl:attribute>
                <xsl:attribute name="font-style">italic</xsl:attribute>
                <xsl:attribute name="color">blue</xsl:attribute>
        <xsl:attribute name="hyphenate">true</xsl:attribute>
        <xsl:attribute name="wrap-option">wrap</xsl:attribute>
    </xsl:attribute-set>
    <xsl:attribute-set name="header-color">
        <xsl:attribute name="background-color">#HEADER_BG_COLOR#</xsl:attribute>
        <xsl:attribute name="color">#HEADER_FONT_COLOR#</xsl:attribute>
    </xsl:attribute-set>


    <!-- Trying this to wrap long words   -->

    <xsl:template match="text()">    
        <xsl:call-template name="intersperse-with-zero-spaces">
            <xsl:with-param name="str" select="."/>
                <xsl:attribute name="color">red</xsl:attribute>
        </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>  
    <!-- long word wrap end  -->


    <xsl:template match="DOCUMENT"> 
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
        <!-- OTHER STUFF AND THE TABLE ... -->                      

        </fo:root>
    </xsl:template>

</xsl:stylesheet>

若要查看是否使用了模板,请更改:

<xsl:value-of select="$c1"/>
致:


要查看模板的效果,请更改&x200B;在&x200B;打印字符,例如。。您将得到更多溢出的表格单元格,但您会知道原因。

您的红色完全不合适。如果这种转变真的奏效,我会感到惊讶。xsl:attribute不允许作为xsl:call模板的子级,请参阅。即使当时允许,您也正在创建文本节点,而文本节点没有属性。谢谢您的回复。不,它不起作用。它只是一如既往地打印表格。模板似乎没有应用于表的内容,也没有应用于报表中的任何其他文本。您在样式表模块中显示的模板是否由其他模块导入?在当前模块或导入当前模块的模块中是否有另一个与文本匹配的模板?如果是这样,该模板将覆盖您显示的模板。APEX使用的XSL-FO基本上就是我显示的XSL-FO,只有几个其他FO:table单元格元素和样式表末尾定义的FO:table列。所以我想没有其他模块导入样式表。此外,没有其他与文本匹配的模板。我对Oracle APEX和XSL_FO都比较陌生,所以我希望能正确回答您的问题。我也不了解Oracle APEX,所以我们很般配。是否有使用xsl:value的表格单元格模板来获取单元格内容的字符串值?如果是,请将的xsl:value更改为xsl:apply-templates,以便使用文本模板。@Toni Graham,是的,现在它可以工作了,谢谢!
<fo:inline color="red"><xsl:value-of select="$c1"/></fo:inline>