我在嘗試使用XSLT對XML文檔進行排序,並希望保留註釋。迄今爲止這麼好,因爲這個問題已經有了一些答案(見相關..)。 但是!沒有這些(優秀)答案涉及到一個XML看起來像這樣:現在會發生什麼使用XSLT對XML進行排序,同時保留多條評論
<xml>
<beatles>
<!-- comment(1): john is actually my favourite -->
<!-- comment(2): John died tragically in 1980 -->
<beatle name="John"/>
<beatle name="Ringo"/>
<beatle name="George"/>
<!-- comment(1): Paul still does live concerts to this day -->
<!-- comment(2): contrary to common folklore, Paul is NOT dead! -->
<beatle name="Paul"/>
</beatles>
</xml>
?我想以按名稱排序甲殼蟲(上帝保佑他們),並保持各甲殼蟲的所有意見的地方,爲了得到這樣的結果:
<xml>
<beatles>
<beatle name="George"/>
<!-- comment(1): john is actually my favourite -->
<!-- comment(2): John died tragically in 1980 -->
<beatle name="John"/>
<!-- comment(1): Paul still does live concerts to this day -->
<!-- comment(2): contrary to common folklore, Paul is NOT dead! -->
<beatle name="Paul"/>
<beatle name="Ringo"/>
</beatles>
</xml>
好老前同輩::評論( )[1]在這裏不起作用。在常規代碼中,我只是對所有前面的註釋做一個反向循環,當我點擊一個非註釋節點時停止;但衆所周知,XSLT的每不能逃脫。
有什麼想法?
TIA!
DF。
好問題,+1。我認爲@ Tim-C給了你一個完美的答案。 – 2010-11-15 13:12:04