문제
는 말이 주신 xml 파일
<root>
<node>x</node>
<node>y</node>
<node>a</node>
</root>
나는 다음을 표시할
ayx
를 사용하여 비슷한
<xsl:template match="/">
<xsl:apply-templates select="root/node"/>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
해결책
쉽습니다!
<xsl:template match="/">
<xsl:apply-templates select="root/node">
<xsl:sort select="position()" data-type="number" order="descending"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
다른 팁
당신이 할 수 있는 이를 사용하여 결과는 다음과 같습니다.을 설정하는 것 이 중요 데이터 type="number"기 때문에 다른 사람,위치 정렬 문자열로 끝나 그 때문에,제 10 회 노드 ge 으로 간주하기 전에 제 2 하나입니다.
<xsl:template match="/">
<xsl:apply-templates select="root/node">
<xsl:sort
select="position()"
order="descending"
data-type="number"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="/">
<xsl:apply-templates select="root/node[3]"/>
<xsl:apply-templates select="root/node[2]"/>
<xsl:apply-templates select="root/node[1]"/>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="."/>
</xsl:template>
제휴하지 않습니다 StackOverflow