具有最小值的 for 循环 [英] For loop with min value
本文介绍了具有最小值的 for 循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我得到了以下 XML 代码,并希望按属性标识符 sort_order
对其进行排序.
I got the following XML code and want to sort it by the attribute identifier sort_order
.
<products>
<product>
<row>
<attribute identifier="SORT_ORDER">60100</attribute>
</row>
<row>
<attribute identifier="SORT_ORDER">60104</attribute>
</row>
</product>
<product>
<row>
<attribute identifier="SORT_ORDER">400</attribute>
</row>
<row>
<attribute identifier="SORT_ORDER">398</attribute>
</row>
</product>
</products>
到目前为止我在 获取元素的帮助下所做的尝试具有最小属性:
for $a in //products/product
order by number ( $a/row[attribute[@identifier='sortOrder']=string(min(//attribute[@identifier='SORT_ORDER']) ) ]/attribute[@identifier='SORT_ORDER'])
return $a
但是上面代码的输出就像输入一样.没有错误.这里出了什么问题?
But the output with the code above is like the input. There is no error. Whats going wrong here?
推荐答案
for $a in //products/product
order by min ($a//attribute[@identifier='SORT_ORDER'])
return $a
这篇关于具有最小值的 for 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文