Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xslt 将标题与下一块的第一行保持一致_Xslt_Xsl Fo - Fatal编程技术网

Xslt 将标题与下一块的第一行保持一致

Xslt 将标题与下一块的第一行保持一致,xslt,xsl-fo,Xslt,Xsl Fo,在这一页的末尾,我不想把“examClin”的标签孤立起来。因此,如果有,标签到达页面的末尾,我需要一行且不超过一行的examClin与@label of examClin一起附加。。。或者两个元素都应该转到下一页。 我够清楚了吗 不同的元素。。。我们到达这一页的末尾 : 将它们放在一个块中(这意味着您必须将两个表行合并为一个)并使用。谢谢Aaron。但我担心,如果这是一篇很长的文本,那么所有内容都将保持在一起,而不仅仅是第一行。因此,它可能会在上一页上留下一个长长的白色块 我创建了以下模

在这一页的末尾,我不想把“examClin”的标签孤立起来。因此,如果有,标签到达页面的末尾,我需要一行且不超过一行的examClin与@label of examClin一起附加。。。或者两个元素都应该转到下一页。 我够清楚了吗

不同的元素。。。我们到达这一页的末尾


: 

将它们放在一个块中(这意味着您必须将两个表行合并为一个)并使用。

谢谢Aaron。但我担心,如果这是一篇很长的文本,那么所有内容都将保持在一起,而不仅仅是第一行。因此,它可能会在上一页上留下一个长长的白色块

我创建了以下模板:想法是找到第一行是什么:第一行的75个字符,但是如果我们在第一行的75个字符之前找到一个回车符,我们将在第一个回车符之前获取字符串

<xsl:template name="elem3">
    <xsl:choose>
        <xsl:when test="child::text()">
            <xsl:variable name="test0" select="substring(child::text(),1,100000)"/> 
            <xsl:variable name="test1" select="substring(child::text(),0,75)"/> 
            <xsl:variable name="test2" select="substring(child::text(),75,100000)"/>
            <xsl:variable name="test3" select="substring-before($test2,' ')"/>
            <xsl:variable name="test4" select="concat($test1,$test3)"/>
            <xsl:variable name="test5" select="substring-after($test2,' ')"/>
             <xsl:variable name="test6" select="substring-before($test1,'&#10;')"/>
           <xsl:variable name="test7" select="substring-after($test0,'&#10;')"/>
            <fo:table-row>
                <fo:table-cell number-columns-spanned="5">
                    <fo:block space-before="2mm">
                        <fo:inline font-weight="bold"><xsl:value-of select="@label"/>: </fo:inline>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
            <xsl:choose>
                <xsl:when test="child::text()">
                    <fo:table-row keep-with-previous="always">
                        <fo:table-cell number-columns-spanned="6" padding-top="2mm" padding-left="1mm" padding-right="1mm">
                            <fo:block white-space-collapse="false" font-style="italic" >
                            <xsl:choose>
                                <xsl:when test="contains($test1,'&#10;')"> <xsl:value-of select="$test6"/></xsl:when>
                                <xsl:otherwise><xsl:value-of select="$test4"/></xsl:otherwise>
                            </xsl:choose>
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                    <fo:table-row>
                        <fo:table-cell number-columns-spanned="5" padding-left="1mm" padding-right="1mm">
                            <fo:block white-space-collapse="false" font-style="italic" >
                                <xsl:choose>
                                    <xsl:when test="contains($test1,'&#10;')"><xsl:value-of select="$test7"/></xsl:when>
                                    <xsl:otherwise> <xsl:value-of select="$test5"/></xsl:otherwise>
                                    </xsl:choose>
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </xsl:when>
            </xsl:choose>
        </xsl:when>
    </xsl:choose>
</xsl:template>

: 
<xsl:template name="elem3">
    <xsl:choose>
        <xsl:when test="child::text()">
            <xsl:variable name="test0" select="substring(child::text(),1,100000)"/> 
            <xsl:variable name="test1" select="substring(child::text(),0,75)"/> 
            <xsl:variable name="test2" select="substring(child::text(),75,100000)"/>
            <xsl:variable name="test3" select="substring-before($test2,' ')"/>
            <xsl:variable name="test4" select="concat($test1,$test3)"/>
            <xsl:variable name="test5" select="substring-after($test2,' ')"/>
             <xsl:variable name="test6" select="substring-before($test1,'&#10;')"/>
           <xsl:variable name="test7" select="substring-after($test0,'&#10;')"/>
            <fo:table-row>
                <fo:table-cell number-columns-spanned="5">
                    <fo:block space-before="2mm">
                        <fo:inline font-weight="bold"><xsl:value-of select="@label"/>: </fo:inline>
                    </fo:block>
                </fo:table-cell>
            </fo:table-row>
            <xsl:choose>
                <xsl:when test="child::text()">
                    <fo:table-row keep-with-previous="always">
                        <fo:table-cell number-columns-spanned="6" padding-top="2mm" padding-left="1mm" padding-right="1mm">
                            <fo:block white-space-collapse="false" font-style="italic" >
                            <xsl:choose>
                                <xsl:when test="contains($test1,'&#10;')"> <xsl:value-of select="$test6"/></xsl:when>
                                <xsl:otherwise><xsl:value-of select="$test4"/></xsl:otherwise>
                            </xsl:choose>
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                    <fo:table-row>
                        <fo:table-cell number-columns-spanned="5" padding-left="1mm" padding-right="1mm">
                            <fo:block white-space-collapse="false" font-style="italic" >
                                <xsl:choose>
                                    <xsl:when test="contains($test1,'&#10;')"><xsl:value-of select="$test7"/></xsl:when>
                                    <xsl:otherwise> <xsl:value-of select="$test5"/></xsl:otherwise>
                                    </xsl:choose>
                            </fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </xsl:when>
            </xsl:choose>
        </xsl:when>
    </xsl:choose>
</xsl:template>