Saxon 9.1.0.7을 사용하여 간단한 외부 조회를 사용하려고 할 때 내 머리카락을 남겨 두었습니다.XSLT 2.0 key() 및 document()를 사용하는 외부 조회
<something>
<monkey>
<genrecode>AAA</genrecode>
</monkey>
<monkey>
<genrecode>BBB</genrecode>
</monkey>
<monkey>
<genrecode>ZZZ</genrecode>
</monkey>
<monkey>
<genrecode>ZER</genrecode>
</monkey>
</something>
그런 다음 조회 파일이 GenreSet_124.xml입니다 :
나는 간단한 소스 파일 dummy.xml이 내가 '무엇<GetGenreMappingObjectsResponse>
<tuple>
<old>
<GenreMapping DepartmentCode="AAA"
DepartmentName="AND - NEWS AND CURRENT AFFAIRS"
Genre="10 - NEWS"/>
</old>
</tuple>
<tuple>
<old>
<GenreMapping DepartmentCode="BBB"
DepartmentName="AND - NEWS AND CURRENT AFFAIRS"
Genre="11 - NEWS"/>
</old>
</tuple>
... lots more
</GetGenreMappingObjectsResponse>
성취하려고 노력하는 것은 단순히 "장르 "값을"DepartmentCode "값을 기반으로합니다.
...
<!-- Set up the genre lookup key -->
<xsl:key name="genre-lookup" match="GenreMapping" use="@DepartmentCode"/>
<xsl:variable name="lookupDoc" select="document('GenreSet_124.xml')"/>
<xsl:template match="/something">
<stuff>
<xsl:for-each select="monkey">
<Genre>
<xsl:apply-templates select="$lookupDoc">
<xsl:with-param name="curr-label" select="genrecode"/>
</xsl:apply-templates>
</Genre>
</xsl:for-each>
</stuff>
</xsl:template>
<xsl:template match="GetGenreMappingObjectsResponse">
<xsl:param name="curr-genrecode"/>
<xsl:value-of select="key('genre-lookup', $curr-genrecode)/@Genre"/>
</xsl:template>
...
내가 가진 문제는 내가 다시 아무것도 얻을 수 없다는 것입니다 : 같은
그래서 내 XSL 보인다. 내가 GenreMapping의 속성으로 모든 조회 데이터를 이동 한
<?xml version="1.0" encoding="UTF-8"?>
<stuff>
<Genre/>
<Genre/>
<Genre/>
<Genre/>
</stuff>
나는 "GetGenreMappingObjectsResponse"그냥 모든 GenreMapping에서 모든 텍스트를 인쇄 할 템플릿 일치 =를 입력 할 때마다 나는 현재 단지 GenreMapping의 하위 요소로 이전에 취득 (DepartmentCode, DepartmentName, Genre)!
나는 내 인생에서 내가 뭘 잘못하고 있는지 알아낼 수 없다. 어떤 helpo/suggestions도 크게 감사 할 것입니다.
는 현재 실제 XSLT 목록을 검색 할 수 있습니다 :.
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- Define the global parameters -->
<xsl:param name="TransformationID"/>
<xsl:param name="TransformationType"/>
<!-- Specify that XML is the desired output type -->
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
<!-- Set up the genre matching capability -->
<xsl:key name="genre-lookup" match="GenreMapping" use="@DepartmentCode"/>
<xsl:variable name="documentPath"><xsl:value-of select="concat('GenreSet_',$TransformationID,'.xml')"/></xsl:variable>
<xsl:variable name="lookupDoc" select="document($documentPath)"/>
<!-- Start the first match on the Root level -->
<xsl:template match="/something">
<stuff>
<xsl:for-each select="monkey">
<Genre>
<xsl:apply-templates select="$lookupDoc/*">
<xsl:with-param name="curr-genrecode" select="string(genrecode)"/>
</xsl:apply-templates>
</Genre>
</xsl:for-each>
</stuff>
</xsl:template >
<xsl:template match="GetGenreMappingObjectsResponse">
<xsl:param name="curr-genrecode"/>
<xsl:value-of select="key('genre-lookup', $curr-genrecode, $lookupDoc)/@Genre"/>
</xsl:template>
</xsl:stylesheet>
TransformationID가 항상 곁에 (124)이다 (그래서 올바른 조회 파일이 열을 유형은 내가 현재 사용하되 의도하고 있지 않다 단지 이름입니다
.하나는 key
기능의 3 매개 변수 버전입니다 세 번째 매개 변수는 당신이 (당신은 키가 작업 할 루트 노드를 지정할 수 있습니다 : XSLT 2.0
어떤 XSLT 컴파일러를 사용하고 있습니까? – Welbog
색슨 -B 9.1.0.7 –
그림. 나는 그 것에 익숙하지 않다. 어쩌면 나중에 Tomalak이 당신을 도울 것입니다. 열쇠가없는 방법이 효과가 있습니까? – Welbog