当前状态
默认情况下,DSpace XMLUI(带有“元数据”焦点的 Mirage、Mirage 2 主题)在搜索结果列表中显示项目,如下所示:
- 当在标题/作者/出版商元数据中找到搜索词时,该项目会显示在“最近添加”列表中(包括摘要的第一部分)。
- 当在摘要中找到搜索字词时,为该项目显示的摘要代码段会“发生变化”,以显示找到搜索字词的位置周围的上下文。
- 当在提取的全文中找到搜索词时,根本不会显示摘要片段。相反,会显示提取的全文的片段,以显示找到搜索词的位置周围的上下文。
在所有三种情况下,搜索词均以粗体显示。
此方法的问题
上述方法会导致用户体验方面的几个问题:
- 上面的逻辑没有向用户解释清楚;搜索结果列表可以是显示摘要开头的项目、显示摘要中间部分的项目以及显示全文片段的项目的混合。
- 提取的全文可能包含“丑陋”的特殊字符,并且通常包含文件名、文件大小以及与用户无关的其他元数据。
- 提取的全文可能来自受限比特流,预览片段可能会泄露本应保密的信息(请参阅 this DSpace bug )。
期望的行为
相反,我希望始终在搜索结果列表中显示项目的抽象片段。摘要片段“转移”以显示搜索词的上下文是可以接受的,但这应该向用户明确。当仅在全文文件中找到搜索词时,应显示摘要的开头,并显示一条消息,表明属于该项目的全文文件包含搜索词。
最佳答案
搜索结果列表的摘要/预览片段部分在 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>
关于xslt - 在 DSpace XMLUI 中,如何更改搜索结果的 "preview"代码段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36024159/