Xml XSLT2.0带键位和零值的排序

Xml XSLT2.0带键位和零值的排序,xml,sorting,xslt,xslt-2.0,Xml,Sorting,Xslt,Xslt 2.0,我遇到了这个xslt排序问题: 我希望能够根据关键权重对元素列表进行排序。键是排序列表结果中的位置。问题是,输入列表中的键位置值为零,当没有指定位置时,结果应保持这些顺序 例如: 输入列表: <document> <HTML weight="7"><DATA>AAA</DATA></HTML> <NEWS weight="5"><DATA>BBB</DATA></NEWS>

我遇到了这个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>
目标:

数据节点内容在排序算法中不起作用

<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

谢谢

您可以将输入示例和预期结果作为代码发布吗?当然,您当前的XSLT代码也可以作为代码发布。既然你发现你的方法有问题,我想你已经测试过了。这似乎与这里提出的问题非常相似:是的,Michael是对的,他已经在链接中回答了一个类似的问题。只需将保留元素映射为@weight>0的元素和@weight=0的普通成员,就可以得到答案!
<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