2015-08-31 72 views
1

我的用例是我有一個項目在另一個項目中有鏈接。例如,項目123456789/152具有元數據字段dc.relation.hasversion=123456789/717。在123456789/152的項目視圖中,如何檢索123456789/717的元數據值?例如,我想從123456789/152檢索dc.language.iso的值123456789/717如何從另一個項目訪問或檢索項目的內容?

我看着相關項目功能DSpace中,但我不知道如何在相關項目列表中顯示的元數據,從該列表中的項目拉動。

我使用DSpace的5.3版幻影2主題

編輯

基於schweerelos答案,下面是我的實際代碼。我正在使用自定義元數據字段dc.relation.languageVersion。基本上,我想鏈接到其他版本,但不顯示值,我將在我的item-view.xsl中顯示其他版本的dc.language.iso。我已經合併的schweerelosanswer這個​​的代碼,但它是只顯示價值dc.relation.languageVersiondc.relation.languageVersion的樣本值是10665.1/9843; 10665.1/9844即不是完整的URI,而只是句柄。

在此先感謝!

實際代碼

<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

相關項目功能使用發現solr的索引,其中「相關性」是通過比較元數據來計算。相關項目的元數據也來自索爾索引,所以不是您可以輕鬆地重複使用的目的。

你不是在說你正在使用什麼DSpace UI變體 - 從你的其他問題我假設XMLUI(如果你包含你的DSpace版本+ UI變體,你的問題可能對其他Stack Overflow用戶更有幫助每次)。

檢索其手柄,你知道,使用document()函數加載該項目的METS文件中的項目的元數據。然後,您可以將模板應用於整個事物或特定的元數據字段。

像這樣(沒有經過測試的,你可能會修改這使其實際工作):

假設你item-view.xsl有這樣的模板(和代碼,以保證模板實際上是所謂的):

<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> 

第一個模板從第一個項目的dc.relation.hasversion中讀取句柄,然後將URL構建到第二個項目的mets文件並加載mets文件。然後它調用第二個模板來加載第二個項目的文件文件。第二個模板讀取dc.language.iso中的值;因爲它是在document()調用的結果上調用的,所以會選擇第二個項目的語言。

+0

嗨安德烈,我更新了我的帖子,包括DSpace版本和主題以及我試過的實際代碼。我可能在代碼中做錯了什麼,因爲結果不是我預期的結果。我懷疑第二項的元數據沒有正確檢索。請諮詢我的代碼有什麼問題,如果我錯過了什麼。提前致謝。 – euler

+0

我可能在我的示例代碼中塞了一些東西,對不起。我會看看我今天晚些時候能否看看。同時,您可以嘗試在document()調用之前發表評論,以查看其他ItemMetadataURL實際包含的內容,如https://github.com/DSpace/DSpace/blob/master/dspace-xmlui/src/main/webapp /themes/dri2xhtml-alt/aspect/artifactbrowser/common.xsl#L163 - 它會將HTML註釋放入您的頁面,您可以使用「查看源代碼」查看該註釋。 – schweerelos

+1

嗨安德烈!非常感謝你的幫助。我現在知道爲什麼沒有檢索到第二個項目的元數據。在' cocoon:/ metadata/handle/'中缺少'/'。它應該是' cocoon:// metadata/handle/'。我幾乎放棄了這一點。 :) Whe!乾杯!!! – euler

相關問題