我在尝试使用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