我坚持这个xslt排序问题:
我希望能够根据键(重量)对元素列表进行排序。关键是排序列表结果中的位置。问题是输入列表的键位置值为零,结果应该在没有分配位置时保持这些顺序。
例如: 输入列表:
<document>
<HTML weight="7"><DATA>AAA</DATA></HTML>
<NEWS weight="5"><DATA>BBB</DATA></NEWS>
<NEWS weight="2"><DATA>CCC</DATA></NEWS>
<ASSET weight="0"><DATA>DDD</DATA></ASSET>
<NEWS weight="0"><DATA>EEE</DATA></NEWS>
<NEWS weight="0"><DATA>FFF</DATA></NEWS>
<NEWS weight="0"><DATA>GGG</DATA></NEWS>
<NEWS weight="0"><DATA>HHH</DATA></NEWS>
<ASSET weight="0"><DATA>III</DATA></NEWS>
<HTML weight="0"><DATA>JJJ</DATA></NEWS>
</document>
目标:
<document>
<ASSET weight="0"><DATA>DDD</DATA></ASSET>
<NEWS weight="2"><DATA>CCC</DATA></NEWS>
<NEWS weight="0"><DATA>EEE</DATA></NEWS>
<NEWS weight="0"><DATA>FFF</DATA></NEWS>
<NEWS weight="5"><DATA>BBB</DATA></NEWS>
<NEWS weight="0"><DATA>GGG</DATA></NEWS>
<HTML weight="7"><DATA>AAA</DATA></HTML>
<NEWS weight="0"><DATA>HHH</DATA></NEWS>
<ASSET weight="0"><DATA>III</DATA></NEWS>
<HTML weight="0"><DATA>JJJ</DATA></NEWS>
</document>
DATA节点内容,无论排序算法如何。
<ASSET weight="0"><DATA>DDD</DATA></ASSET> must be the first "zero" weight item because there isn't a weight=1 in the input list.
<NEWS weight="2"><DATA>CCC</DATA></NEWS> is the second element because weight=2=position in the result list.
<NEWS weight="0"><DATA>EEE</DATA></NEWS> must be the second "zero" because there isn't a weight=3 in the input list.
and so on
感谢