【发布时间】:2016-08-30 10:40:54
【问题描述】:
我必须从一个目录中获取所有文档,并使用下面的查询来做同样的事情。现在我需要返回基于 EffectiveDate 元素排序的结果。我们可以使用 order by 以及此代码
let $news :=xdmp:directory("/news/","1")
for $d in $news
return $d
-- Result -----
<?xml version="1.0" encoding="UTF-8"?>
<NewsEntity xmlns="http://jnj.com/news">
<uuid xmlns="">868e8a3a-058d-4b2d-8d69-0696f75ec97f</uuid>
<headLine>HeadLine 4</headLine>
<contributor>User 4</contributor>
<effectiveDate>2016-08-31</effectiveDate>
</NewsEntity>
<?xml version="1.0" encoding="UTF-8"?>
<NewsEntity xmlns="http://jnj.com/news">
<uuid xmlns="">311eeede-2560-4142-b882-b666ab08c9f8</uuid>
<headLine>HeadLine 3</headLine>
<contributor>User 3</contributor>
<effectiveDate>2016-08-28</effectiveDate>
</NewsEntity>
<?xml version="1.0" encoding="UTF-8"?>
<NewsEntity xmlns="http://jnj.com/news">
<uuid xmlns="">9bb67977-a217-425f-82e4-b4366e80d7c4</uuid>
<headLine>HeadLine 2</headLine>
<contributor>User 2</contributor>
<effectiveDate>2016-08-30</effectiveDate>
</NewsEntity>
【问题讨论】: