在 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>除了将开始和结束标签折叠在一行中之外,还有其他方法可以实现吗?
因为如果属性值不是纯文本行,而是一些复杂计算的结果(例如使用或标记),那么将所有代码折叠在一行中以避免前导和尾随空格会导致样式表非常难看。