2016-03-15 18 views
1

現狀在DSpace XMLUI中,如何更改搜索結果的「預覽」片段?

DSpace的XMLUI(幻影,幻影2個主題爲「元數據」的重點)默認顯示在搜索結果列表項目如下:

  1. 當搜索項在標題被發現/作者/出版商元數據,該項目顯示爲「最近添加」列表(包括摘要的第一部分)。
  2. 當在摘要中找到搜索項時,項目顯示的摘要片段「移位」以顯示找到搜索項的位置的上下文。
  3. 當在提取的全文中找到搜索項時,摘要片段根本不顯示。取而代之的是,提取的全文的片段被顯示爲顯示找到搜索項的地方的上下文。

在所有三種情況下,搜索條件都以粗體顯示。

使用這種方法的問題

上面的方法會導致用戶體驗方面的幾個問題:

  • 上述邏輯不明確給用戶;搜索結果列表可以是所示摘要開頭的項目組合,顯示摘要中間部分的項目以及顯示全文摘錄的項目。
  • 提取的全文可能包含「醜陋」的特殊字符,通常會包含與用戶關係不大的文件名,文件大小和其他元數據。
  • 提取的全文可能來自受限制的比特流,並且預覽片段可能會顯示應該保密的信息(請參閱this DSpace bug)。

期望的行爲

相反,我想總是顯示在搜索結果列表項的抽象片段。抽象片段「移動」以顯示搜索詞的上下文是可以接受的,但是這應該向用戶明確。當僅在全文文件中找到搜索項時,應該顯示摘要的開頭,以及屬於該項的全文文件包含搜索項的消息。

回答

2

搜索結果列表的摘要/預覽片段部分在discovery.xml中生成,例如starting here針對Mirage 2中文件的當前版本。如下定製「選擇」語句將產生期望的結果(雖然它在i18n方面並不健全):

<xsl:choose> 
    <xsl:when test="dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item/dri:hi"> 
    <!-- 
     search term found in abstract - show context 
     around search term location(s) 
    --> 
    <div class="abstract"> 
     <strong>Search term found in abstract:</strong> 
     <xsl:for-each select="dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item"> 
     <xsl:text>… </xsl:text><xsl:apply-templates select="."/><xsl:text> …</xsl:text> 
     <br/> 
     </xsl:for-each> 
    </div> 
    </xsl:when> 
    <xsl:when test="dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item"> 
    <!-- 
     search term not found in abstract but the item has an abstract 
     - show first part of abstract like in recently added lists 
    --> 
    <div class="abstract"> 
     <xsl:value-of select="util:shortenString(dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item, 220, 10)"/>      
    </div> 
    </xsl:when> 
</xsl:choose> 
<xsl:if test="not(dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item/dri:hi) and dri:list[@n=(concat($handle, ':fulltext'))]"> 
    <!-- 
     search term not found in abstract but found in fulltext file - 
     show message _instead_ of preview; if there is an abstract 
     then it will already be shown via the choose statement above 
    --> 
    <strong>(Search term found in fulltext file)</strong> 
</xsl:if> 
+0

當我試圖實現util:shortenString函數時,出現以下錯誤:'org.apache.xpath.domapi.XPathStylesheetDOM3Exception:前綴必須解析爲命名空間:util' – veeTrain

+0

我通過將其添加到xsl :文件開始處的樣式表:'xmlns:util =「org.dspace.app.xmlui.utils.XSLUtils」',並且可能還會排除util作爲結果前綴。 – veeTrain

0

謝謝schweerelos!以你爲例,我們對我們的發現做了以下改變。XSL:

首先,我們需要一個額外的項目,以便執行將字符串縮短添加到樣式表:

<xsl:stylesheet 
    xmlns:util="org.dspace.app.xmlui.utils.XSLUtils" 
    ... 
    exclude-result-prefixes="xalan encoder i18n dri util ..."> 

然後我們修改了:fulltext分支是一個否則,顯示的第一220個字符摘要(只要它存在)。

<xsl:choose> 
    <xsl:when test="dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item/dri:hi"> 
     <div class="abstract"> 
      <xsl:for-each select="dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item"> 
       <xsl:apply-templates select="."/> 
       <xsl:text>...</xsl:text> 
       <br/> 
      </xsl:for-each> 
     </div> 
    </xsl:when> 

    <xsl:otherwise> <!-- NEW APPROACH STARTS ON THIS LINE --> 
     <div class="abstract"> 
      <xsl:value-of select="util:shortenString(dri:list[@n=(concat($handle, ':dc.description.abstract'))]/dri:item, 220, 10)"/> 
     </div> 
    </xsl:otherwise> 
</xsl:choose> 

我們發現這是一個可接受的權衡,並提供了一致的外觀。您可以在記錄中提供的dc.description.abstract或dc.description.abstract的開頭處看到Hit Highlighting(查找搜索項已找到(KWIC))的位置。

而且在抽象的文本本身目前禁運(或無限期地限制),那麼那些有可能會顯示在舊呈現受限制的內容只是顯示任何搜索詞「這個項目的抽象的限制......」因爲dc.description.abstract場填充該文本。

上述方法(<xsl:otherwise>部分)取代了以下內容。

拒絕(如交付的)做法:

<xsl:when test="dri:list[@n=(concat($handle, ':fulltext'))]"> 
    <div class="abstract"> 
     <xsl:for-each select="dri:list[@n=(concat($handle, ':fulltext'))]/dri:item"> 
     <xsl:apply-templates select="."/> 
     <xsl:text>...</xsl:text> 
     <br/> 
     </xsl:for-each> 
    </div> 
</xsl:when> 

該文件是在一個意想不到的位置,如果我的理解更多的發展過程是如何工作的,我可以大概我們主題刪除此文件夾,但作爲它的立場,它在dri2xhtml-alt主題中進行了編輯。我沒有想到會在那裏找到影響這種行爲的文件,但似乎很清楚它可以在那裏改變它。你應該知道

\DSpaceRepo\dspace-xmlui\src\main\webapp\themes\dri2xhtml-alt\aspect\artifactbrowser\discovery.xsl

最後一兩件事 - 如果你正在編輯這個文件,並希望改變對你清楚地看到,你需要保持清除瀏覽器歷史記錄/緩存或執行新的搜索。由於這個原因,編輯過程有點艱鉅(不能反映最新的變化),直到我找到一個好的工作流程。

相關問題