그룹을 사용하는 데 다소 익숙하며 position()을 사용하여 그룹의 하위 집합을 선택할 수 있기를 원합니다.XSLT2 그룹의 하위 집합 선택
이미이 코드는 내가 원하는대로 (필요에 따라 그룹을 생성하고 올바른 출력.) 작업 한
<xsl:template match="Locations">
<table>
<tbody>
<xsl:for-each-group select="Location" group-by="Country">
<xsl:sort data-type="text" order="ascending" select="."/>
<xsl:for-each-group select="current-group()" group-by="current-grouping-key()">
</xsl:for-each-group>
<tr>
<td class="country"><xsl:value-of select="current-grouping-key()"/></td>
</tr>
<xsl:for-each-group select="current-group()" group-by="City">
<xsl:sort data-type="text" order="ascending" select="current-grouping-key()"/>
<tr>
<td class="city"><xsl:value-of select="fn:current-grouping-key()"/></td>
</tr>
</xsl:for-each-group>
</xsl:for-each-group>
</tbody>
</table>
</xsl:template>
난 그냥 통해 2를 얻기 위해 원하는 경우 제 4 국가 태그, 그 일을 어떻게 하죠? 나는 position()을 시도했지만 숫자를 얻는 대신 그룹 키 값 (예 : CA)을 얻고 있습니다. 어떤 도움을 크게 감상 할 수
<Locations> <Location> <Country>US</Country> <City>New York</City> </Location> <Location> <Country>US</Country> <City>Houston</City> </Location> <Location> <Country>MX</Country> <City>Cancun</City> </Location> <Location> <Country>CH</Country> <City>Zurich</City> </Location> <Location> <Country>CA</Country> <City>Toronto</City> </Location> <Location> <Country>DE</Country> <City>Berlin</City> </Location> <Location> <Country>JP</Country> <City>Tokyo</City> </Location> <Location> <Country>GB</Country> <City>London</City> </Location> <Location> <Country>CA</Country> <City>Edmonton</City> </Location> </Locations>
:
이
는 소스 XML이다. 미리 감사드립니다.
당신은 당신이이 경우에 예상되는 출력을 보여줄 수 있습니까? 'position()'을 사용하려고 시도하면 도움이 될 것입니다. 고맙습니다! –