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()を次のように使用すると、
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>
回答:
回答№1は2ザ fn:distinct-values(...)
機能は動作します 原子値XMLフラグメントを入力すると、それらは暗黙的にアトマイズされます。
同じ行を2回以上含めずに元の問題を解決するには、行をアトミック値(文字列など)として表し、それらの一意性を何らかの方法でチェックする必要があります。 fn:deep-equal($seq1, $seq2)
XQLを構造的に比較する
アトミック識別子によるアプローチを選択した場合は、XQuery 3.0 地図 既に見た識別子を使って一意性チェックを高速化することができます。もう一つの考えは使用することです group by
同等の行を集め、グループごとに1行を出力します。