XSLT：如何在不按內容排序的情況下反轉輸出

a
x
c
z


z
c
x
a


最佳答案

I will present two XSLT solutions:

I. XSLT 1.0 with recursion Note that this solution works for any node-set, not only in the case when the nodes are siblings:

This transformation:





when applied on this xml document:


a
x
c
z



produces the wanted result:

z
c
x
a


II. XSLT 2.0 solution :





When this transformation is applied on the same xml document, the same correct result is produced.