前の回答のスタイルシートを機能させるには、スタイルシートに名前空間宣言を (接頭辞付きで) 追加し、すべてのノード名に新しい名前空間接頭辞を使用します。
したがって、これは次のようにする必要があります。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:y="http://www.yahoo.com/xmlns/ApplicationTest"
>
<xsl:variable name="u2" select="document('usaa22.xml')"/>
<xsl:template match="y:city">
<xsl:choose>
<xsl:when test="$u2//y:city[y:street=current()/y:street]">
<xsl:copy>
<xsl:apply-templates select="$u2//y:city[y:street=current()/y:street]/* " />
</xsl:copy>
</xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@* | node() " />
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="@* | node() " />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
注意: あなたの xml の変更は正しくないようです:
<?xml version="1.0" xmlns="http://www.yahoo.com/xmlns/ApplicationTest" encoding="UTF-8"?>
プロローグは<?xml
名前空間を許可しません。
名前空間は、xml ファイルの最初の要素に追加する必要があります。
<country xmlns="http://www.yahoo.com/xmlns/ApplicationTest">