如何从另一个项目访问或检索项目的mets内容? [英] How to access or retrieve mets content of an item from another item?

查看:25
本文介绍了如何从另一个项目访问或检索项目的mets内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用例是我有一个项目在另一个项目中有一个链接.例如,项目 123456789/152 有一个元数据字段 dc.relation.hasversion=123456789/717.在123456789/152的item视图中,如何获取123456789/717元数据的值?例如,我想从 123456789/152 中检索 123456789/717dc.language.iso 值.

我查看了 DSpace 中的相关项目功能,但我不知道 相关项目 列表中显示的元数据是如何从该列表中的项目中提取的.

我正在使用 DSpace 5.3 版 Mirage 2 主题.

编辑

基于 schweerelos 答案,以下是我的实际代码.我正在使用自定义元数据字段 dc.relation.languageVersion.基本上,我想链接到其他版本,但不是显示值,而是在我的 item-view.xsl 中显示其他版本的 dc.language.iso>.我已经合并了 answer>schweerelos到代码中的这个问题,但它只是显示值dc.relation.languageVersion.dc.relation.languageVersion 的示例值为 10665.1/984310665.1/9844 即不是完整的 URI,而是句柄.

提前致谢!

实际代码

<xsl:if test="dim:field[@element='relation' and @qualifier='languageVersion' andescentant::text()]"><div class="col-sm-6 col-print-4 item-page-field-wrapper"><h5><i18n:text>xmlui.dri2xhtml.METS-1.0.item-languageVersion</i18n:text></h5><跨度><xsl:for-each select="dim:field[@element='relation' and @qualifier='languageVersion']"><xsl:apply-templates select="./node()" mode="showRelatedLang"/><xsl:if test="count(following-sibling::dim:field[@element='relation' and @qualifier='languageVersion']) != 0"><xsl:text>;</xsl:text></xsl:if></xsl:for-each></span>

</xsl:if></xsl:模板><xsl:template match="dim:field[@element='relation' and @qualifier='languageVersion' andescentant::text()]" mode="showRelatedLang"><xsl:variable name="otherItemMetadataURL"><xsl:text>cocoon:/metadata/handle/</xsl:text><xsl:value-of select="."/><xsl:text>/mets.xml</xsl:text></xsl:变量><xsl:apply-templates select="document($otherItemMetadataURL)" mode="showLang"/></xsl:模板><xsl:template match="dim:field[@element='language' and @qualifier='iso' 和后代::text()]" mode="showLang"><xsl:value-of select="util:isoLanguageToDisplay(node())"/></xsl:模板>

解决方案

相关项目功能使用 Discovery solr 索引,其中相关性"是通过比较元数据来计算的.相关项目的元数据也来自 solr 索引,因此您无法轻松地重复使用.

您没有说您使用的是什么 DSpace UI 变体——从您的其他问题中我假设是 XMLUI(如果您每次都包含 DSpace 版本 + UI 变体,您的问题可能对其他 Stack Overflow 用户更有帮助)时间).

要检索您知道句柄的项目的元数据,请使用 document() 函数加载该项目的mets 文件.然后,您可以将模板应用于整个事物或特定的元数据字段.

类似这样的东西(完全未经测试,您可能需要对其进行修改才能使其真正起作用):

假设你的 item-view.xsl 有这样的模板(以及确保模板被实际调用的代码):

<xsl:template match="dim:field[@element='relation' and @qualifier='hasversion' andescentant::text()]" mode="showRelatedLang"><xsl:variable name="otherItemMetadataURL"><xsl:text>cocoon://metadata/handle/</xsl:text><xsl:value-of select="."/><xsl:text>/mets.xml</xsl:text></xsl:变量><xsl:apply-templates select="document($otherItemMetadataURL)" mode="showLang"/></xsl:模板><xsl:template match="dim:field[@element='language' and @qualifier='iso' 和后代::text()]" mode="showLang"><xsl:value-of select="."/></xsl:模板>

第一个模板从第一个项目的 dc.relation.hasversion 读取句柄,然后构造第二个项目的mets 文件的URL 并加载mets 文件.然后它将第二个模板调用到加载第二个项目的mets 文件的结果.第二个模板从 dc.language.iso 读取值;因为它是在 document() 调用的结果上调用的,所以这将选择 第二个 项目的语言.

My use case is I have an item that has a link in another item. For example, item 123456789/152 has a metadata field dc.relation.hasversion=123456789/717. Within the item view of 123456789/152, how can I retrieve the values of the metadata of 123456789/717? For example, I want to retrieve the dc.language.iso value of 123456789/717 from 123456789/152.

I looked at the Related items feature in DSpace but I don't know how the metadata displayed in the Related items list were pulled from the items in that list.

I am using DSpace Version 5.3 Mirage 2 Theme.

EDIT

Based on schweerelos answer, below is my actual code. I am using a custom metadata field dc.relation.languageVersion. Basically, I want to link to that other version but instead of displaying the value, I will display the dc.language.iso of the other version in my item-view.xsl. I've incorporated the answer of schweerelos to this question in the code but it is just displaying the value of dc.relation.languageVersion. Sample values of dc.relation.languageVersion are 10665.1/9843; 10665.1/9844 ie not the complete URI but just the handle.

Thanks in advance!

Actual code

<xsl:template name="itemSummaryView-DIM-other-language">
    <xsl:if test="dim:field[@element='relation' and @qualifier='languageVersion' and descendant::text()]">
        <div class="col-sm-6 col-print-4 item-page-field-wrapper">
            <h5><i18n:text>xmlui.dri2xhtml.METS-1.0.item-languageVersion</i18n:text></h5>
            <span>
                <xsl:for-each select="dim:field[@element='relation' and @qualifier='languageVersion']">
                    <xsl:apply-templates  select="./node()" mode="showRelatedLang"/>
                    <xsl:if test="count(following-sibling::dim:field[@element='relation' and @qualifier='languageVersion']) != 0">
                        <xsl:text>; </xsl:text>
                    </xsl:if>
                </xsl:for-each>
            </span>
        </div>
    </xsl:if>
</xsl:template>

<xsl:template match="dim:field[@element='relation' and @qualifier='languageVersion' and descendant::text()]" mode="showRelatedLang">
    <xsl:variable name="otherItemMetadataURL">
        <xsl:text>cocoon:/metadata/handle/</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>/mets.xml</xsl:text>
    </xsl:variable>
    <xsl:apply-templates select="document($otherItemMetadataURL)" mode="showLang"/>
</xsl:template>

<xsl:template match="dim:field[@element='language' and @qualifier='iso' and descendant::text()]" mode="showLang">
    <xsl:value-of select="util:isoLanguageToDisplay(node())"/>
</xsl:template>

解决方案

The related items feature uses the Discovery solr index, where "relatedness" is calculated by comparing metadata. The related items' metadata also comes from the solr index, so not something you can re-use easily for your purpose.

You're not saying what DSpace UI variant you're using -- from your other questions I'm assuming XMLUI (your questions might be even more helpful for other Stack Overflow users if you included your DSpace version + UI variant every time).

To retrieve the metadata of an item whose handle you know, use the document() function to load that item's mets file. You can then apply templates to the whole thing or to specific metadata fields.

Something like this (totally untested, you will probably have to modify this to make it actually work):

Say your item-view.xsl has templates like this (and code to ensure the template is actually called):

<xsl:template match="dim:field[@element='relation' and @qualifier='hasversion' and descendant::text()]" mode="showRelatedLang">        
    <xsl:variable name="otherItemMetadataURL">        
        <xsl:text>cocoon://metadata/handle/</xsl:text>
        <xsl:value-of select="."/>
        <xsl:text>/mets.xml</xsl:text>
    </xsl:variable>        
    <xsl:apply-templates select="document($otherItemMetadataURL)" mode="showLang"/>
</xsl:template>

<xsl:template match="dim:field[@element='language' and @qualifier='iso' and descendant::text()]" mode="showLang">
    <xsl:value-of select="."/>
</xsl:template>

The first template reads the handle from the first item's dc.relation.hasversion, then constructs the URL to the second item's mets file and loads the mets file. It then calls the second template to the result of loading the second item's mets file. The second template reads the value from dc.language.iso; because it's called on the result of the document() call, this will select the second item's language.

这篇关于如何从另一个项目访问或检索项目的mets内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆