我在XSLT中遇到了一些问题。我需要写这样的东西:
$city1 = substring-after($address, ',')
$city2 = substring-before($city1, ' -')
$city = $city2 or $city1 if $city2 empty
我已经有了这个
<xsl:variable name="city1" select = "substring-after($adress,',')" />
<xsl:variable name="city2" select = "substring-before($city1,'-')" />
<xsl:variable name="city" select = "normalize-space($city2 or $city1)" />
但最后一轮不起作用......我该如何解决?
答案 0 :(得分:0)
试试这个
<xsl:variable name="city1" select = "normalize-space(substring-after($address,','))" />
<xsl:variable name="city2" select = "normalize-space(substring-before($city1,'-'))" />
<xsl:variable name="city">
<xsl:choose>
<xsl:when test="$city2 != ''">
<xsl:value-of select="$city2"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$city1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>