1

我在 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)" /> 

但是最后一轮不起作用...我该如何解决?

4

1 回答 1

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>
于 2013-11-13T14:20:56.157 回答