문의하고 싶습니다. 조회 테이블을 통해 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) 키를 사용하는 조회가 둘 이상의 노드를 리턴 할 것으로 예상합니까? 그렇다면 출력이 올바를 것인가? –