다음 xml 파일이 있습니다.속성 값을 기반으로 xsl : key에 의해 반환 된 가방에서 중복 제거
<Bank>
<Person personId="1" type="1071" deleted="0">
</Person>
<Person personId="2" type="1071" deleted="0">
</Person>
<Person personId="3" type="1071" deleted="0">
</Person>
<Account>
<Role personId="1" type="1025" />
</Account>
<Account>
<Role personId="1" type="1025" />
</Account>
<Account>
<Role personId="1" type="1018" />
</Account>
<Account>
<Role personId="3" type="1025" />
<Role personId="1" type="1018" />
</Account>
<Account>
<Role personId="2" type="1025" />
</Account>
</Bank>
다음 XSL 변환.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" encoding="ISO-8859-1" />
<xsl:strip-space elements="*" />
<xsl:key name="roleKey"
match="Role[(@type = '1025' or @type = '1018' or @type = '1022' or @type = '1023') and not(@validTo)]"
use="@personId" />
<xsl:template match="Person">
<xsl:value-of select="@personId" />
<xsl:variable name="roles" select="key('roleKey', @personId)" />
<xsl:for-each select="$roles">
<xsl:text>;</xsl:text><xsl:value-of select="@type" />
</xsl:for-each>
<xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>
실제 결과는 다음과 내가 중복 type
값을 제거하고 싶습니다. 내가 this website에서 키워드 following
또한 Muenchian 방법으로 트릭을 포함하는 팁을 시도
1;1025;1018
2;1025
3;1025
1;1025;1025;1018;1018
2;1025
3;1025
다음과 같이 예상되는 결과는해야한다 .... 그들은 personId
속성으로 정의 된 Person
컨텍스트에서만 중복을 제거하려는 반면에 전체 문서를 탐색하고 Person
요소 각각에 대해 중복을 매치하는 것처럼 보이는 것처럼 작동하지 않습니다.
key
에 의해 반환 된 가방에서 중복 된 것을 어떻게 제거합니까? 아니면 내가 원하는 것을 인쇄하기 위해 xsl:for-each
에서 사용할 수있는 방법이 있을까요?
XSLT 1.0에서 사용할 수있는 것만 사용할 수 있습니다. XSLT 2.0 프로세서를 사용할 수있는 가능성은 없습니다.