お尋ねします。ルックアップテーブルでxmlデータをチェックする条件を追加する可能性があります。ルックアップテーブルに値がなければ、出力にconst 8を追加しますか? XSLTコード:ルックアップテーブルでxmlデータをチェックする条件を追加する方法
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="Department" match="Department" use="../Collection"/>
<xsl:template match="/">
<document>
<xsl:apply-templates/>
</document>
</xsl:template>
<xsl:template match="line">
<xsl:variable name="inputDep" select="field[@id='3']"/>
<Department>
<xsl:for-each select="document('lookup.xml')">
<xsl:for-each select="key('Deparment',$inputDep)">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</Department>
</xsl:template>
</xsl:stylesheet>
ルックアップテーブル:
<document>
<line-item>
<Collection>1</Collection>
<Department>3</Department>
</line-item>
<line-item>
<Collection>2</Collection>
<Department>1</Department>
</line-item>
<line-item>
<Collection>3</Collection>
<Department>2</Department>
</line-item>
</document>
xmlファイル:
<document>
<line id="0">
<field id="3"><![CDATA[1]]></field>
</line>
<line id="1">
<field id="3"/>
</line>
<line id="2">
<field id="3"/><![CDATA[4]]></field>
</line>
</document>
結果:
<Department>3<Department>
<Department>8<Department>
<Department>8<Department>
なぜ内側のfor-eachループですか? Deparment(sic)キーを使用したルックアップが複数のノードを返すことを期待していますか?そうであれば出力は正しいでしょうか? xmlファイル用ではないルックアップテーブル用にそれぞれ –