xslt: substring-before
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have the folowing xml code: 14 3 12 7 3 78 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: background-image:url('../icon_ .png'); Problem is that substring before doesn't return anything when there's no space. Any easy way around this? 回答1: You can use xsl:when and contains : background-image:url('../icon_ .png'); background-image:url('../icon_ .png'); 回答2: You can make sure that there is always a space, maybe not the prettiest but at least it's compact :) 回答3: