在eXist-DB4.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是
http://localhost:8081/exist/apps/deheresi/doc/ 和相应结果的祖先节点的值。
tei:text/@xml:id(始终将作为查询中返回的任何tei:seg内容的祖先节点)。
我注意到在@link中的<config>参数上有一个可用的kwic:summarize()属性,但是我不知道如何从返回的结果中动态地获取源文档节点来填充它。
在此之前,非常感谢您。
发布于 2018-11-14 21:31:55
结果表明,节点$hit允许访问源文档的其余部分(或内存中的副本)。因此,我能够使用$hit/ancestor将URL构建为字符串
let $doclink := concat("http://localhost:8081/exist/apps/deheresi/doc/", $hit/ancestor::tei:text/data(@xml:id)) 然后将该字符串输入函数参数@link中。
kwic:summarize($hit, <config width="80" table="yes" link="{$doclink}"/>)https://stackoverflow.com/questions/53301714
复制相似问题