How to access or retrieve mets content of an item from another item?

老子叫甜甜 提交于 2019-12-11 12:14:57

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/32303880/how-to-access-or-retrieve-mets-content-of-an-item-from-another-item

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!