Xpath eXist db-XQuery-Lucene-使用回调参数在KWIC函数中控制输出

Xpath eXist db-XQuery-Lucene-使用回调参数在KWIC函数中控制输出,xpath,lucene,xquery,exist-db,Xpath,Lucene,Xquery,Exist Db,(此问题与试图实现其他人几年前在上提出的问题的答案有关) 在eXist db 4.4中,我有以下Lucene索引定义: <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>

(此问题与试图实现其他人几年前在上提出的问题的答案有关)

在eXist db 4.4中,我有以下Lucene索引定义:

<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
查询通过
kwic返回以下内容:summary
函数。
tei:note
tei:del
均未被忽略

<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>
…它请求此功能:

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未定义上下文序列

我不知道如何在查询和回调之间进行通信,也许还不知道在这种情况下如何编写回调函数(请注意,回调函数从问题顶部的
集合.xconf
中查找要忽略的元素)

<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>
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)