1
我遇到了distinct-values()函數的問題。XQuery - distinct-values()正在擺脫我的表
for $b in doc("KS0.xml") /bncDoc/stext/div/u/s/w
let $c := normalize-space(lower-case($b))
where $c = "has"
return <tr><td>{$c}</td><td>{$b/following-sibling::w[1]}</td><td></td></tr>
上面的代碼給我下面的HTML輸出:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<tr>
<th>Target</th>
<th>Successor</th>
<th>Frequency</th>
</tr>
<tr>
<td>has</td>
<td>
<w c5="AV0" hw="there" pos="ADV">there</w>
</td>
<td/>
</tr>
<tr>
<td>has</td>
<td>
<w c5="AT0" hw="a" pos="ART">a </w>
</td>
<td/>
</tr>
</table>
凡有3列,但是當我使用不同的值()像這樣:
distinct-values(
for $b in doc("KS0.xml") /bncDoc/stext/div/u/s/w
let $c := normalize-space(lower-case($b))
where $c = "has"
return <tr><td>{$c}</td><td>{$b/following-sibling::w[1]}</td><td></td></tr>
)
我得到此:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<tr>
<th>Target</th>
<th>Successor</th>
<th>Frequency</th>
</tr>hasthere hasn't haslarge hasbeen hasgone hasdone hasa hasalthough hasintentions hasjust hasgot hasto hasnow hasin hastropical hassince hasdare </table>
你實際上沒有說過你想要達到的目標。您只展示了一些無法實現的代碼。 –