(这个问题与试图实现对几年前别人在
Ignored XML elements show up near eXist-db's lucene search results
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:tei="http://www.tei-c.org/ns/1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<lucene>
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
<text qname="tei:seg"/>
<text qname="tei:persName"/>
<text qname="tei:placeName"/>
<ignore qname="tei:note"/>
<ignore qname="tei:pb"/>
<ignore qname="tei:gap"/>
<ignore qname="tei:del"/>
<ignore qname="tei:orig"/>
<inline qname="tei:supplied"/>
</lucene>
</index
它将应用于始终如下所示的内容:
<seg type="dep_event" subtype="event" xml:id="MS609-0209-2">Item. Alia
<del type="notary" rend="expunctus">die</del> vice vidit
<placeName type="event_loc" nymRef="#home_of_Cap-de-Porc">in eodem hospitio</placeName>
<persName nymRef="#Bernard_Cap-de-Porc_MSP-AU" role="her">Bernardum</persName>
<note type="public">Assumed Bernard Cap-de-Porc based on <foreign xml:lang="LA">eodem hospitio</foreign>.</note> et socium suum, hereticos. Et vidit ibi cum eis
<persName nymRef="#Arnald_Godalh_MSP-AU" ana="#pAdo" role="par">Arnaldum<lb break="y" n="7"/>Godalh</persName>; et
<persName nymRef="#Guilhem_de_Rosengue_MSP-AU" ana="#pAdo #pBring" role="par">W<supplied reason="expname">illelmum</supplied>,
<roleName type="fam">filium dicti testis</roleName></persName>,
qui duxit ipsum testis ad dictos hereticos; et ipsum
<persName nymRef="#Peire_Cap-de-Porc_MSP-AU" ana="#pAdo" role="par">Cap de Porc</persName> et
<persName nymRef="#Susanna_Cap-de-Porc_MSP-AU" ana="#pAdo" role="par"/>uxorem eius. Et
<persName nymRef="#Arnald_de_Rosengue_MSP-AU" ana="#pAdo" role="par"/>ipse testis et omnes alii adoraverunt<lb break="y" n="8"/>ibi dictos hereticos. Et
<date type="event_date" when="1240">sunt V anni vel circa</date>.
</seg>
tei:seg
,但我想忽略内部的某些元素,例如
tei:note
和
tei:del
let $query :=
<query>
<term>hospitio</term>
</query>
for $hit in collection($URIdata)//tei:text/tei:body//tei:seg[@type="dep_event"][ft:query(.,$query)]
order by ft:score($hit) descending
return
kwic:summarize($hit, <config width="80" table="yes"/>)
查询返回以下到
kwic:summarize
功能。也不是
tei:注意
泰伊:德尔
被忽视了。。。。
<tr>
<td class="previous">Item. Alia die vice vidit
in eodem </td>
<td class="hi">hospitio</td>
<td class="following">Bernardum Assumed Bernard Cap-de-Porc based on e...</td>
</tr>
this SO question
)通过一个附加的
callback
参数。我试图在查询中添加回调:
kwic:summarize($hit, <config width="80" table="yes"/>, search:kwic-filter)
declare %private function search:kwic-filter($node as node(), $mode as xs:string) as xs:string? {
let $ignored-elements := doc(concat($globalvar:URIdb,"collection.xconf"))//*:ignore/@qname/string()
let $ignored-elements :=
for $ignored-element in $ignored-elements
let $ignored-element := substring-after($ignored-element, ':')
return $ignored-element
return
if (local-name($node/parent::*) = ($ignored-elements))
then ()
else
if ($mode eq 'before')
then concat($node, ' ')
else concat(' ', $node)
错误:“child::search:kwic filter”的XPDY0002上下文序列未定义
我缺少如何在查询和回调之间进行通信,以及在这种情况下如何编写回调函数(注意,回调函数从
collection.xconf