Background
Maintain readable XSL source code while generating HTML without excessive breaks that introduce spaces between sentences and their terminating punctuation. From Rethinking XSLT:
White space in XSLT stylesheets is especially problematic because it serves two purposes: (1) for formatting the XSLT stylesheet itself; and (2) for specifying where whitespace should go in the output of XSLT-processed XML data.
Problem
缩略语
<xsl:if test="@min-time < @max-time">
for
<xsl:value-of select="@min-time" />
to
<xsl:value-of select="@max-time" />
minutes
</xsl:if>
<xsl:if test="@setting">
on <xsl:value-of select="@setting" /> heat
</xsl:if>
.
This, for example, generates the following output (with whitespace exactly as shown):
for
2
to
3
minutes
.
所有主要浏览器都生产:
for 2 to 3 minutes .
Nearly flawless, except for the space between the word minutes
and the punctuation. The desired output is:
for 2 to 3 minutes.
也许可以通过在XSL模板中删除登革线和新线来消除空间,但这意味着有XSL来源代码。
Workaround
最初,预期产出按变量进行总结,然后写如下:
<xsl:value-of select="normalize-space($step)" />.
在此之前,我试图将<代码>和>;span>要素纳入变量。 <代码><span>ss从来未出现在生成的超文本代码内。 下述法典也不正确:
<xsl:copy-of select="normalize-space($step)" />.
Technical Details
风格已经使用:
<xsl:strip-space elements="*" />
<xsl:output indent="no" ... />
Related
Question
How do you tell the XSLT processor to eliminate that space?
谢谢!