如何在 DSpace 中显示收获物品的缩略图?
How to display thumbnails from harvested items in DSpace?
我正在尝试显示收获物品的缩略图。我对采集选项的设置是采集元数据和对比特流的引用(需要 ORE 支持)。在查找有关 DSpace 如何在简单视图中显示所收集项目的比特流的文件名和文件大小的代码时,我发现在 https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L375-L378
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM" />
</xsl:when>
以及 https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L81-L84 中的完整项目记录视图。
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="./mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemDetailView-DIM" />
</xsl:when>
因此,在 item-view.xsl
中找到的代码似乎正在调用在 ORE.xsl
中找到的模板匹配。
现在,查看 //mets:fileSec/mets:fileGrp[@USE='ORE']
中收获物品的示例 mets.xml
文件,我们可以看到它引用了 /bitstream/handle/10862/3360/ORE.xml
中的 ORE.xml
。
<mets:fileSec>
<mets:fileGrp USE="ORE">
<mets:file GROUPID="group_file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUM="7afebcfcf393395503377219395e3926" MIMETYPE="text/xml" SIZE="4137" ID="file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUMTYPE="MD5">
<mets:FLocat LOCTYPE="URL" xlink:href="/bitstream/handle/10862/3360/ORE.xml?sequence=1&isAllowed=y" xlink:type="locator" xlink:title="ORE.xml"/>
</mets:file>
</mets:fileGrp>
</mets:fileSec>
根据在 ORE.xsl
中找到的模板匹配,我们可以看到文件名和文件大小是从以下代码生成的:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<div class="item-page-field-wrapper table">
<h5>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</h5>
<xsl:for-each select="document($AtomMapURL)/atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']">
<xsl:variable name="link_href" select="@href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='ORIGINAL']
or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
<xsl:call-template name="itemSummaryView-DIM-file-section-entry">
<xsl:with-param name="href" select="@href" />
<xsl:with-param name="mimetype" select="@type" />
<xsl:with-param name="label-1" select="'title'" />
<xsl:with-param name="label-2" select="'title'" />
<xsl:with-param name="title" select="@title" />
<xsl:with-param name="label" select="@title" />
<xsl:with-param name="size" select="@length" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
查看/bitstream/handle/10862/3360/ORE.xml
,我们可以看到除了ORIGINAL
包外,TEXT
和THUMBNAIL
包在收割时也被捕获了。
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf" length="2310365" rel="http://www.openarchives.org/ore/terms/aggregates" title="ediblecrustacea.pdf" type="application/pdf"/>
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf" length="177699" rel="http://www.openarchives.org/ore/terms/aggregates" title="edible-crust-errata.pdf" type="application/pdf"/>
<oreatom:triples>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="http://hdl.handle.net/10862/152/ore.xml#atom">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceItem"/>
<dcterms:modified>2011-06-07T06:45:26Z</dcterms:modified>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/35/edible-crust-errata.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/36/ediblecrustacea.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/32/ediblecrustacea.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/33/edible-crust-errata.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
</oreatom:triples>
现在我的目标是捕获并重用在 /atom:entry/oreatom:triples/rdf:Description[@rdf:about][dcterms:description='THUMBNAIL']
中找到的 url,并将其作为在 itemSummaryView-DIM-thumnail
and mets:file
的代码中找到的缩略图的 src
模板,有点热链接到原始缩略图。顺便说一句,此项 视图中的文件无论如何都不是很好,所以...
关于在简单视图中显示缩略图,我正在考虑在 itemSummaryView-DIM-thumbnail
模板中有一个 <xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
即:
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Checking if Thumbnail is restricted and if so, show a restricted image -->
<xsl:choose>
<xsl:when test="contains($src,'isAllowed=n')"/>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
我现在的问题是我不知道如何在 ORE.xml
文件中引用缩略图的 url。我还注意到名称和文件大小是根据上面的 ORE.xsl
代码从 /atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']
中提取的。
提前致谢!
更新
这是我所做的:
我修改了源服务器的 [dspace]/config/crosswalks/oai/metadataFormats/ore.xsl
,这样当使用 ore
作为元数据格式时,它将在 OAI
输出的 <atom:link rel="http://www.openarchives.org/ore/terms/aggregates">
部分公开缩略图,但我必须清理 oai 的缓存并在源服务器中完全重新导入 OAI。此外,我必须重置并从采集服务器导入采集以包含新生成的 ORE.xml
文件。我所做的修改是将 ore.xsl
的第 67 行从
更改为
<xsl:if test="doc:field[@name='name']/text() = 'ORIGINAL'">
进入:
<xsl:if test="doc:field[@name='name']/text() = 'ORIGINAL' or doc:field[@name='name']/text() = 'THUMBNAIL'">
然后在 item-view.xsl
中,我将这一行包含在 <xsl:template name="itemSummaryView-DIM-thumbnail">
中:
然后,在 [dspace]/webapps/xmlui/themes/Mirage2/xsl/aspect/artifactbrowser/ORE.xsl
中我加入了这些行:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="link_href" select="@href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1]
or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="@href"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
除了在源项目中有多个缩略图的情况下,即使在我的测试条件 <xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1] or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
中,它也会显示多个缩略图。请参阅下面的屏幕截图:
此外,我宁愿不修改源服务器的人行横道目录中的 ore.xsl
因此 post:
更新 2 - 缩略图现在显示在简单的项目视图中
我做了什么:
在 <xsl:template name="itemSummaryView-DIM-thumbnail">
中,我在第 195 行之后插入了以下代码:
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
然后,我在 ORE.xsl
中添加了这个模板:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(@rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/@rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
我收获的物品现在在物品摘要视图中显示缩略图:
如果我也可以让缩略图显示在项目列表和搜索结果中,那就太好了但是现在,我不知道如何匹配和select缩略图url.我不知道如何从 <xsl:template match="mets:fileSec" mode="artifact-preview">
模板中引用它们。
为了我将来的参考,这是我为显示收获物品的缩略图所做的。
此答案基于 DSpace 5x Mirage2 主题,但也可以应用于 DSpace 6x Mirage2。
在 item-view.xsl
中,找到 <xsl:template name="itemSummaryView-DIM-thumbnail">
块,然后插入此代码:
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
在 <xsl:otherwise>
块之前。下面是完整的模板块:
<xsl:template name="itemSummaryView-DIM-thumbnail">
<div class="thumbnail">
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<img alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
然后编辑 ORE.xsl
并在 </xsl:stylesheet>
结束标记之前插入下面的代码。
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img alt="Thumbnail" class="img-responsive">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(@rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/@rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
要在项目列表中显示缩略图,请编辑 common.xsl
并找到此代码:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL</xsl:text>
并将其更改为:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL,ORE</xsl:text>
要在搜索结果中显示缩略图,请在 [dspace-src]/dspace/modules/xmlui-mirage2/src/main/webapp/themes/Mirage2/xsl/aspect/discovery
目录下的文件 discovery.xsl
中找到上述同一行代码,然后像在 common.xsl
文件中一样对其进行修改。
本回答所有文件修改均在[dspace-src]dspace/modules
目录下进行。
可在此处找到此代码的实际示例:SEAFDEC External Publications
我正在尝试显示收获物品的缩略图。我对采集选项的设置是采集元数据和对比特流的引用(需要 ORE 支持)。在查找有关 DSpace 如何在简单视图中显示所收集项目的比特流的文件名和文件大小的代码时,我发现在 https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L375-L378
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM" />
</xsl:when>
以及 https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L81-L84 中的完整项目记录视图。
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="./mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="./mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemDetailView-DIM" />
</xsl:when>
因此,在 item-view.xsl
中找到的代码似乎正在调用在 ORE.xsl
中找到的模板匹配。
现在,查看 //mets:fileSec/mets:fileGrp[@USE='ORE']
中收获物品的示例 mets.xml
文件,我们可以看到它引用了 /bitstream/handle/10862/3360/ORE.xml
中的 ORE.xml
。
<mets:fileSec>
<mets:fileGrp USE="ORE">
<mets:file GROUPID="group_file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUM="7afebcfcf393395503377219395e3926" MIMETYPE="text/xml" SIZE="4137" ID="file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUMTYPE="MD5">
<mets:FLocat LOCTYPE="URL" xlink:href="/bitstream/handle/10862/3360/ORE.xml?sequence=1&isAllowed=y" xlink:type="locator" xlink:title="ORE.xml"/>
</mets:file>
</mets:fileGrp>
</mets:fileSec>
根据在 ORE.xsl
中找到的模板匹配,我们可以看到文件名和文件大小是从以下代码生成的:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<div class="item-page-field-wrapper table">
<h5>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</h5>
<xsl:for-each select="document($AtomMapURL)/atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']">
<xsl:variable name="link_href" select="@href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='ORIGINAL']
or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
<xsl:call-template name="itemSummaryView-DIM-file-section-entry">
<xsl:with-param name="href" select="@href" />
<xsl:with-param name="mimetype" select="@type" />
<xsl:with-param name="label-1" select="'title'" />
<xsl:with-param name="label-2" select="'title'" />
<xsl:with-param name="title" select="@title" />
<xsl:with-param name="label" select="@title" />
<xsl:with-param name="size" select="@length" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
查看/bitstream/handle/10862/3360/ORE.xml
,我们可以看到除了ORIGINAL
包外,TEXT
和THUMBNAIL
包在收割时也被捕获了。
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf" length="2310365" rel="http://www.openarchives.org/ore/terms/aggregates" title="ediblecrustacea.pdf" type="application/pdf"/>
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf" length="177699" rel="http://www.openarchives.org/ore/terms/aggregates" title="edible-crust-errata.pdf" type="application/pdf"/>
<oreatom:triples>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="http://hdl.handle.net/10862/152/ore.xml#atom">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceItem"/>
<dcterms:modified>2011-06-07T06:45:26Z</dcterms:modified>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/35/edible-crust-errata.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/36/ediblecrustacea.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/32/ediblecrustacea.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/33/edible-crust-errata.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
</oreatom:triples>
现在我的目标是捕获并重用在 /atom:entry/oreatom:triples/rdf:Description[@rdf:about][dcterms:description='THUMBNAIL']
中找到的 url,并将其作为在 itemSummaryView-DIM-thumnail
and mets:file
的代码中找到的缩略图的 src
模板,有点热链接到原始缩略图。顺便说一句,此项 视图中的文件无论如何都不是很好,所以...
关于在简单视图中显示缩略图,我正在考虑在 itemSummaryView-DIM-thumbnail
模板中有一个 <xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
即:
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Checking if Thumbnail is restricted and if so, show a restricted image -->
<xsl:choose>
<xsl:when test="contains($src,'isAllowed=n')"/>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
我现在的问题是我不知道如何在 ORE.xml
文件中引用缩略图的 url。我还注意到名称和文件大小是根据上面的 ORE.xsl
代码从 /atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']
中提取的。
提前致谢!
更新
这是我所做的:
我修改了源服务器的 [dspace]/config/crosswalks/oai/metadataFormats/ore.xsl
,这样当使用 ore
作为元数据格式时,它将在 OAI
输出的 <atom:link rel="http://www.openarchives.org/ore/terms/aggregates">
部分公开缩略图,但我必须清理 oai 的缓存并在源服务器中完全重新导入 OAI。此外,我必须重置并从采集服务器导入采集以包含新生成的 ORE.xml
文件。我所做的修改是将 ore.xsl
的第 67 行从
<xsl:if test="doc:field[@name='name']/text() = 'ORIGINAL'">
进入:
<xsl:if test="doc:field[@name='name']/text() = 'ORIGINAL' or doc:field[@name='name']/text() = 'THUMBNAIL'">
然后在 item-view.xsl
中,我将这一行包含在 <xsl:template name="itemSummaryView-DIM-thumbnail">
中:
然后,在 [dspace]/webapps/xmlui/themes/Mirage2/xsl/aspect/artifactbrowser/ORE.xsl
中我加入了这些行:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="atom:link[@rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="link_href" select="@href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1]
or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="@href"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
除了在源项目中有多个缩略图的情况下,即使在我的测试条件 <xsl:if test="/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1] or not(/atom:entry/oreatom:triples/rdf:Description[@rdf:about=$link_href])">
中,它也会显示多个缩略图。请参阅下面的屏幕截图:
此外,我宁愿不修改源服务器的人行横道目录中的 ore.xsl
因此 post:
更新 2 - 缩略图现在显示在简单的项目视图中
我做了什么:
在 <xsl:template name="itemSummaryView-DIM-thumbnail">
中,我在第 195 行之后插入了以下代码:
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
然后,我在 ORE.xsl
中添加了这个模板:
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(@rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/@rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
我收获的物品现在在物品摘要视图中显示缩略图:
如果我也可以让缩略图显示在项目列表和搜索结果中,那就太好了但是现在,我不知道如何匹配和select缩略图url.我不知道如何从 <xsl:template match="mets:fileSec" mode="artifact-preview">
模板中引用它们。
为了我将来的参考,这是我为显示收获物品的缩略图所做的。
此答案基于 DSpace 5x Mirage2 主题,但也可以应用于 DSpace 6x Mirage2。
在 item-view.xsl
中,找到 <xsl:template name="itemSummaryView-DIM-thumbnail">
块,然后插入此代码:
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
在 <xsl:otherwise>
块之前。下面是完整的模板块:
<xsl:template name="itemSummaryView-DIM-thumbnail">
<div class="thumbnail">
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file[@GROUPID=../../mets:fileGrp[@USE='CONTENT']/mets:file[@GROUPID=../../mets:fileGrp[@USE='THUMBNAIL']/mets:file/@GROUPID][1]/@GROUPID]/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[@USE='THUMBNAIL']/mets:file/mets:FLocat[@LOCTYPE='URL']/@xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<img alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[@USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
然后编辑 ORE.xsl
并在 </xsl:stylesheet>
结束标记之前插入下面的代码。
<xsl:template match="mets:fileGrp[@USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[@LOCTYPE='URL']//@*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img alt="Thumbnail" class="img-responsive">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(@rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/@rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
要在项目列表中显示缩略图,请编辑 common.xsl
并找到此代码:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL</xsl:text>
并将其更改为:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL,ORE</xsl:text>
要在搜索结果中显示缩略图,请在 [dspace-src]/dspace/modules/xmlui-mirage2/src/main/webapp/themes/Mirage2/xsl/aspect/discovery
目录下的文件 discovery.xsl
中找到上述同一行代码,然后像在 common.xsl
文件中一样对其进行修改。
本回答所有文件修改均在[dspace-src]dspace/modules
目录下进行。
可在此处找到此代码的实际示例:SEAFDEC External Publications