I have the folowing xml code:
<weather-code>14 3</weather-code>
<weather-code>12</weather-code>
<weather-code>7 3 78</weather-code>
Now i'd like to only grab the first number of each node to set a background image. So for each node i have the folowing xslt:
<xsl:attribute name="style">
background-image:url('../icon_<xsl:value-of select="substring-before(weather-code, ' ')" />.png');
</xsl:attribute>
Problem is that substring before doesn't return anything when there's no space. Any easy way around this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…