在XSLT样式表中,我如何在
例如,以下样式表:
虽然我希望它输出:
<xsl:attribute>
标记内移除前导和尾随空格?例如,以下样式表:
<xsl:template match="/">
<xsl:element name="myelement">
<xsl:attribute name="myattribute">
attribute value
</xsl:attribute>
</xsl:element>
</xsl:template>
输出:
<myelement myattribute=" attribute value "/>
虽然我希望它输出:
<myelement myattribute="attribute value"/>
除了将<xsl:attribute>
的开始和结束标记合并成一行以外,还有其他实现方法吗?
因为如果属性值不是纯文本行,而是某些复杂计算的结果(例如使用或标签),则将所有代码合并成一行以避免前导和尾随空格将导致样式表非常丑陋。
<xsl:choose>
元素,则将所有代码折叠成一行以获得所需结果会使样式表看起来非常丑陋。 - Theodore Lytras<xsl:choose>
被文本节点“夹住”了;将每个节点都用<xsl:text>
包装起来可以有效地去除空格。问题解决了,谢谢! - Theodore Lytras