xsl获取键中未进行比较的节点



在这个例子中,我有这个xml

<CityStates>
<States>
<State Abbr="AL">Alabama</State>
<State Abbr="AK">Alaska</State>
<State Abbr="AZ">Arizona</State>
<State Abbr="AR">Arkansas</State>
</States>
<Cities>
<City State="NY" >New York</City>
<City State="CA" >Los Angeles</City>
<City State="AZ" >Chicago</City>
<City State="AR" >Houston</City>
<City State="AR" >Philadelphia</City>   
</Cities>
</CityStates>

我只想查看没有State和Key((的节点xsl是这样的:

<xsl:key name="keyState" match="State" use="@Abbr"/>
<xsl:template match="/">
<xsl:for-each select="//City">
<xsl:value-of select="City"/>
</xsl:for-each>
</xsl:template>

使用谓词City[not(key('keyState', @State))],即

<xsl:for-each select="//City[not(key('keyState', @State))]">
<xsl:value-of select="."/>
</xsl:for-each>

尝试以下操作:

<xsl:template match="/CityStates">
<xsl:for-each select="Cities/City[not(key('keyState', @State))]" >
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>

您尚未公布预期结果。您可能希望在xsl:value-of指令之后添加某种分隔符。

相关内容

  • 没有找到相关文章

最新更新