그 다음이 '배열'당신은 XSLT 문서 자체를 참조하는 또 다른 변수를 정의 할 수 있습니다에 액세스 할 수 있도록
<xsl:variable name="inline-array">
<class sort="1">Senior</class>
<class sort="2">Junior</class>
<class sort="3">Sophomore</class>
<class sort="4">Freshman</class>
</xsl:variable>
처럼, 사용자 정의 순서를 나타내는 변수를 정의 할 수 있습니다 :
당신이 정렬 될 때
<xsl:variable name="array"
select="document('')/*/xsl:variable[@name='inline-array']/*" />
이 이제 지정된 클래스 이름에 대한 종류 속성을 조회 할 수 있습니다 (현재는() 현재의 노드를 나타냅니다 분류되는)
다음 샘플 XML이를 적용하면 예를 들어
<xsl:sort select="$array[. = current()/@class]/@sort" />
, 여기에 ... 전체 XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:variable name="inline-array">
<class sort="1">Senior</class>
<class sort="2">Junior</class>
<class sort="3">Sophomore</class>
<class sort="4">Freshman</class>
</xsl:variable>
<xsl:variable name="array"
select="document('')/*/xsl:variable[@name='inline-array']/*"/>
<xsl:template match="/objects">
<xsl:copy>
<xsl:apply-templates select="object">
<xsl:sort select="$array[. = current()/@class]/@sort" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
입니다
<objects>
<object id="2" name="Junior Jo" class="Junior" />
<object id="1" name="Senior Sue" class="Senior" />
<object id="4" name="Freshman Frank" class="Freshman" />
<object id="3" name="Sophie Sophomore" class="Sophomore" />
</objects>
<objects>
<object id="1" name="Senior Sue" class="Senior"></object>
<object id="2" name="Junior Jo" class="Junior"></object>
<object id="3" name="Sophie Sophomore" class="Sophomore"></object>
<object id="4" name="Freshman Frank" class="Freshman"></object>
</objects>
을 반환 다음
XSLT 1.0 또는 2.0을 사용하고 있습니까? 색슨은 당신을위한 선택입니까? – LarsH
나는 Saxon을 사용하고 어떤 버전이라도 사용할 수있다. 일반적으로 나는 3을 사용한다. –