感谢 schweerelos!通过您的示例,我们对 discovery.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 的开头看到找到搜索词的位置 (KWIC) 的 Hit Highlighting。
如果摘要的文本本身目前被禁运(或无限期限制),那么任何原本会在旧演示文稿中显示受限制内容的搜索词只会显示“此项目的摘要受限制...”,因为 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>
该文件位于意外位置,如果我对开发过程的工作方式有更多了解,我可能会将其放入 OUR 主题文件夹中,但就目前而言,它是在 dri2xhtml-alt 中编辑的主题。我没想到会在那里找到影响此行为的文件,但似乎很清楚它可以在那里更改它。
\DSpaceRepo\dspace-xmlui\src\main\webapp\themes\dri2xhtml-alt\aspect\artifactbrowser\discovery.xsl
您应该知道的最后一件事 - 如果您正在编辑此文件并期望更改对您来说很明显,您需要不断清除浏览器历史记录/缓存或执行新的搜索。由于这个原因,编辑过程有点费力(似乎没有反映最新的变化),直到我找到了一个好的工作流程。