0
我有一些XML數據和一個XSL FO樣式表來格式化XML。我有下面的XML文檔:XSL FO:在段落之間打印一條空行
<Content>
<Para>Paragraph One.</Para>
<Para />
<Para>Paragraph Two.</Para>
<Para />
<Para>Paragraph Three.</Para>
</Content>
與FO樣式造型會後所需的輸出:
Paragraph One.
Paragraph Two.
Paragraph Three.
我得到的實際產量低於總有兩個空行。
Paragraph One.
Paragraph Two.
Paragraph Three.
我使用的樣式表的代碼是:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:variable name="NewLine">
<xsl:text> </text>
</xsl:variable>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="pageSetup">
<fo:region-body region-name="xsl-region-body" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="pageSetup">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates />
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="Para">
<fo:block
linefeed-treatment="preserve"
white-space-collapse="false">
<xsl:choose>
<xsl:when test="text() != ''">
<xsl:value-of select="text()" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$NewLine" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
什麼是插入換行的意義呢?在段落之後添加額外的空白空間?如果是這樣,你應該爲你的''添加填充或邊距。 –
potame