【发布时间】:2021-06-23 19:26:58
【问题描述】:
XML 源中有数据,我想将其转换为一个由换行符分隔并消除最后一个换行符的列表。
这就是我目前所拥有的......
XML
<pool>yes</pool>
<balcony>no</balcony>
<garage>yes</garage>
XSLT
<xsl:variable name="pool"><xsl:if test="pool='yes'"><xsl:text>Pool </xsl:text></xsl:if></xsl:variable>
<xsl:variable name="balcony"><xsl:if test="balcony='yes'"><xsl:text>Balcony </xsl:text></xsl:if></xsl:variable>
<xsl:variable name="garage"><xsl:if test="garage='yes'"><xsl:text>Garage </xsl:text></xsl:if></xsl:variable>
<xsl:variable name="features"><xsl:value-of select="concat($pool,$balcony,$garage)"/></xsl:variable>
<xsl:value-of select="$features"/>
此时我有:
Pool<newline>
Garage<newline>
blank line
我想删除最后一个换行符和空行。
有没有办法摆脱它,或者改变我将列表放在一起以生成列表的方式?
【问题讨论】:
-
请提供minimal reproducible example,而不是脱离上下文的代码sn-ps。