xsl获取不在键中比较的节点

xsl get node that not compare in key

在这个例子中我有这个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 with the 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 指令后添加某种定界符。