在 eXist-DB 4.4 中,我设法部署了一个简单的 Lucern 查询,其中 KWIC 输出为表。
我有一个tei:xml
看起来像这个样本的文档集合:
<TEI xml:id="MS609-0001.xml">
<text xml:id="MS609-0001">
[...]
<seg type="dep_event" subtype="event" xml:id="MS609-0001-1">
<pb n="1r"/>
<lb break="n" n="1"/>
<date type="deposition_date" when="1245-05-27" cert="high">Anno
Domini M° CC° XL° quinto VI Kalendas Iunii.</date>
<persName nymRef="#Arnald_Garnier_MSP-AU" role="dep">Arnaldus Garnerii</persName>
testis iuratus dixit quod vidit in
<placeName type="event_loc" nymRef="#home_of_Cap-de-Porc">domo
<persName nymRef="#Peire_Cap-de-Porc_MSP-AU" role="own">Petri de Sancto Andrea</persName>
</placeName>
<lb break="y" n="2"/>
<persName nymRef="#Bernard_Cap-de-Porc_MSP-AU" role="her">B<supplied reason="expname">ernardum</supplied> de Sancto Andrea</persName>,
fratrem dicti Petri, et socium eius, hereticos. Et vidit ibi cum eis dictum
<persName nymRef="#Peire_Cap-de-Porc_MSP-AU" ana="#uAdo" role="par">P<supplied reason="expname">etrum</supplied> de Sancto Andrea</persName> et
<persName nymRef="#Susanna_Cap-de-Porc_MSP-AU" ana="#uAdo" role="par">uxor dicti<lb break="y" n="3"/>Petri</persName>. Et
<persName nymRef="#Arnald_Garnier_MSP-AU" ana="#pAdo" role="par"/>ipse
testis adoravit ibi dictos hereticos, sed non vidit alios adorare. Et
<date type="event_date" when="1239">sunt VI anni vel circa</date>.
<seg type="inq_int" subtype="specific_question">Et quando ipse testis exivit<lb break="y" n="4"/>domum invenit
<persName nymRef="#Guilhem_de_Rosengue_MSP-AU" key="inqint" ana="#pIntra" role="ref">Willelmus de Rozergue</persName> intrantem ad dictos hereticos.</seg>
</seg>
<seg>
[...]
</seg>
[...]
<text>
<TEI>
使用此函数调用 KWIC:
xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
import module namespace kwic="http://exist-db.org/xquery/kwic";
let $query :=
<query>
<wildcard>heret*</wildcard>
</query>
for $hit in collection('/db/apps/deheresi/data/')//tei:seg[ft:query(.,$query)]
order by ft:score($hit) descending
return
kwic:summarize($hit, <config width="80" table="yes" />)
例如,我将这些结果作为表格获得:
<tr>
<td class="previous">...ernardum de Sancto Andrea,
fratrem dicti Petri, et socium eius, </td>
<td class="hi">hereticos</td>
<td class="following">. Et vidit ibi cum eis dictum
Petrum de Sancto Andrea et
...</td>
</tr>
<tr>
<td class="previous">...r dicti Petri. Et ipse
testis adoravit ibi dictos </td>
<td class="hi">hereticos</td>
<td class="following">, sed non vidit alios adorare. Et
sunt VI anni vel circa...</td>
</tr>
我想做的是将文本包装在<td class="hi"/>
指向网站上可查看的源文档的 url 中。站点逻辑非常“干净”,因此第一个条目<td class="hi">
看起来像这样:
<td class="hi"><a href="http://localhost:8081/exist/apps/deheresi/doc/MS609-0001">hereticos</a></td>
url 是一个 concat
http://localhost:8081/exist/apps/deheresi/doc/
以及相应结果的祖先节点的值
tei:text/@xml:id
(它将始终是查询中返回的任何tei:seg
内容的祖先节点)。
我注意到in 的参数@link
上有一个可用的属性,但我不知道如何从返回的结果中动态获取源文档节点以填充它。<config>
kwic:summarize()
提前谢谢了。