【发布时间】:2011-03-07 05:18:01
【问题描述】:
我有以下 xml 代码:
<weather-code>14 3</weather-code>
<weather-code>12</weather-code>
<weather-code>7 3 78</weather-code>
现在我只想抓取每个节点的第一个数字来设置背景图像。因此,对于每个节点,我都有以下 xslt:
<xsl:attribute name="style">
background-image:url('../icon_<xsl:value-of select="substring-before(weather-code, ' ')" />.png');
</xsl:attribute>
问题是当没有空格时,之前的子字符串不会返回任何内容。有什么简单的方法吗?
【问题讨论】: