XSL document() 関数を使用して、xsl:key を使用して外部 XML ドキュメント内のアイテムを検索しようとしています。document() を使用する代わりに、(C# で XmlDocument を使用して) 2 つの XML ファイルをマージするだけで、xsl:key 部分を機能させることができます。ただし、どちらの XML ファイルも非常に大きく、場合によっては「メモリ不足」エラーが発生し始めています。また、xls:key を使用できるようにする必要があります。そうしないと、処理に数時間かかります。
XSLT 2.0 では、次のようなことができると思います。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="lookupDoc" select="document('CodeDescriptions.xml')" />
<xsl:key name="LookupDescriptionByCode" match="Code/@description" use="../@code" />
<xsl:template match="ItemCode">
<xsl:call-template name="MakeSpanForCode">
<xsl:with-param name="code" select="text()" />
</xsl:call-template>
</xsl:template>
<xsl:template name="MakeSpanForCode">
<xsl:param name="code" />
<xsl:element name="span">
<xsl:attribute name="title">
<xsl:value-of select="$lookupDoc/key('LookupDescriptionByCode', $code)" />
</xsl:attribute>
<xsl:value-of select="$code" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
しかし、XSLT 1.0 でこれをどのように達成するのでしょうか?