【发布时间】:2015-11-23 00:57:38
【问题描述】:
我有一个 XQuery 文件,它在输出中返回大量数据。我只想在我的输出中显示前 5 条记录。这是xquery代码。
<html>
<body>
<table border='1'>
<tr><td>Target</td><td>Successor</td><td>Probability</td></tr>
{
let $target := "has"
let $occurrences := doc("KS0.xml")//u//s/w[lower-case(normalize-space()) = $target]
for $successor in distinct-values($occurrences/following-sibling::w[1])
let $frequency := $occurrences/following-sibling::w[1][. = $successor]
let $probability := count($frequency) div count(//u//s/w[lower-case(normalize-space()) = lower-case(normalize-space($successor))])
order by count($frequency) descending
return <tr>
<td>{$target}</td>
<td>{$successor}</td>
<td>{$probability}</td>
</tr>
}
</table>
</body>
</html>
【问题讨论】: