Xslt 1.0 覆盖主页中最近添加的列表

Xslt 1.0 覆盖主页中最近添加的列表,xslt-1.0,dspace,Xslt 1.0,Dspace,我想知道是否可以覆盖主页中最近添加的列表。默认行为是,无论发布日期如何,列表中都会显示任何新提交的项目。是否有方法覆盖它,以便仅显示最近提交的出版物,例如两年内发布的出版物(或者如果dc.date.issued=>2014,则显示有条件的) 我使用的是DSpace 5.3幻影2主题 更新 使用的答案,下面是我尝试的代码: <xsl:template match="dri:referenceSet[@rend='recent-submissions']"> <xsl:fo

我想知道是否可以覆盖主页中最近添加的列表。默认行为是,无论发布日期如何,列表中都会显示任何新提交的项目。是否有方法覆盖它,以便仅显示最近提交的出版物,例如两年内发布的出版物(或者如果dc.date.issued=>2014,则显示有条件的

我使用的是DSpace 5.3幻影2主题

更新

使用的答案,下面是我尝试的代码:

<xsl:template match="dri:referenceSet[@rend='recent-submissions']">
    <xsl:for-each select="dri:reference">
        <xsl:variable name="externalMetadataURL">
            <xsl:text>cocoon:/</xsl:text>
            <xsl:value-of select="@url"/>
            <!-- No options selected, render the full METS document -->
        </xsl:variable>
        <xsl:comment> External Metadata URL: <xsl:value-of select="$externalMetadataURL"/> </xsl:comment>
        <xsl:variable name="issue-date"  select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
        <xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>

        <!--
           Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
           An XSLT extension would be needed to computer the current date.
        -->
        <xsl:if test="$issue-date &lt; 2014">
            <xsl:apply-templates select="."/>
        </xsl:if>
    </xsl:for-each>
</xsl:template>
这就是生成的DRI:

<div id="aspect.discovery.SiteRecentSubmissions.div.site-home" rend="primary repository" n="site-home">
    <div id="aspect.discovery.SiteRecentSubmissions.div.site-recent-submission" rend="secondary recent-submission" n="site-recent-submission">
        <head>Recently Added</head>
        <referenceSet id="aspect.discovery.SiteRecentSubmissions.referenceSet.site-last-submitted" rend="recent-submissions" n="site-last-submitted" type="summaryList">   
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2260/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2265/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2261/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2262/mets.xml"/>
            <reference repositoryID="10862" type="DSpace Item" url="/metadata/handle/10862/2263/mets.xml"/>
        </referenceSet>
        <p id="aspect.discovery.SiteRecentSubmissions.p.recent-submission-view-more" rend="recentSubmissionViewMore" n="recent-submission-view-more">
            <xref target="/recent-submissions">View more</xref>
        </p>
    </div>
</div>

最近添加

查看更多

即使我删除了我的条件(例如
),我仍然有空白,如查看源代码和下图所示


有什么建议吗?

最近项目的DSpace配置文件(discovery.xml)将允许您设置用于提取最近项目的元数据字段。您可以在不同的集合中更改该字段。您可以设置要提取的最大项数,但不能设置其他筛选条件

您需要使用如下逻辑在XSLT中设置该标准

<xsl:template match="dri:referenceSet[@rend='recent-submission']">
   <xsl:for-each select="dri:reference">
     <xsl:variable name="issue-date"  select="document(@url)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>

    <!-- 
       Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
       An XSLT extension would be needed to computer the current date.
    -->
    <xsl:if test="$issue-date &gt; 2014">
      <ul class="ds-artifact-list">
        <xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/>
      </ul>
    </xsl:if>
  <xsl:for-each>
</xsl:template>


下面的stackoverflow回答说明了如何将java函数合并到DSpace XSLT样式表中:请参见最近项目的DSpace配置文件(discovery.xml)将允许您设置用于提取最近项目的元数据字段。您可以在不同的集合中更改该字段。您可以设置要提取的最大项数,但不能设置其他筛选条件

您需要使用如下逻辑在XSLT中设置该标准

<xsl:template match="dri:referenceSet[@rend='recent-submission']">
   <xsl:for-each select="dri:reference">
     <xsl:variable name="issue-date"  select="document(@url)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>

    <!-- 
       Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
       An XSLT extension would be needed to computer the current date.
    -->
    <xsl:if test="$issue-date &gt; 2014">
      <ul class="ds-artifact-list">
        <xsl:apply-templates select="*[not(name()='head')]" mode="summaryList"/>
      </ul>
    </xsl:if>
  <xsl:for-each>
</xsl:template>


下面的stackoverflow回答说明了如何将java函数合并到DSpace XSLT样式表中:请参见

Ok,下面的代码是我使用Mirage 2主题覆盖主页中最近提交的列表的代码。谢谢你的回答

<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[@rend='recent-submissions']">
    <xsl:for-each select="dri:reference">
        <xsl:variable name="externalMetadataURL">
            <xsl:text>cocoon:/</xsl:text>
            <xsl:value-of select="@url"/>
            <!-- No options selected, render the full METS document -->
        </xsl:variable>
        <xsl:variable name="issue-date"  select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
        <!--
           Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
           An XSLT extension would be needed to computer the current date.
        -->
        <xsl:if test="substring($issue-date,1,4) = date:year()">
            <xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>
            <xsl:comment> Current year is: <xsl:value-of select="date:year()"/> </xsl:comment>
            <ul class="ds-artifact-list list-unstyled">
                <xsl:apply-templates select="." mode="summaryList"/>
            </ul>
        </xsl:if>
    </xsl:for-each>
</xsl:template>

茧:/
外部元数据URL:
本年度为:
注意,我使用了

<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[@rend='recent-submissions']">


这是因为如果我只使用
,它也会在您单击
查看更多链接后覆盖列表。我还使用了
date:year()。谢谢你的回答

<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[@rend='recent-submissions']">
    <xsl:for-each select="dri:reference">
        <xsl:variable name="externalMetadataURL">
            <xsl:text>cocoon:/</xsl:text>
            <xsl:value-of select="@url"/>
            <!-- No options selected, render the full METS document -->
        </xsl:variable>
        <xsl:variable name="issue-date"  select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
        <!--
           Assuming dates conform to YYYY-MM-DD syntax, a simple string compare should work.
           An XSLT extension would be needed to computer the current date.
        -->
        <xsl:if test="substring($issue-date,1,4) = date:year()">
            <xsl:comment> External Metadata URL: <xsl:value-of select="$issue-date"/> </xsl:comment>
            <xsl:comment> Current year is: <xsl:value-of select="date:year()"/> </xsl:comment>
            <ul class="ds-artifact-list list-unstyled">
                <xsl:apply-templates select="." mode="summaryList"/>
            </ul>
        </xsl:if>
    </xsl:for-each>
</xsl:template>

茧:/
外部元数据URL:
本年度为:
注意,我使用了

<xsl:template match="dri:div[@id='aspect.discovery.SiteRecentSubmissions.div.site-recent-submission']/dri:referenceSet[@rend='recent-submissions']">


这是因为如果我只使用
,它也会在您单击
查看更多链接后覆盖列表。我还使用了
date:year()

<!-- Otherwise use default handling of body -->
<xsl:otherwise>
    <xsl:apply-templates />
</xsl:otherwise>

据此:

<!-- Otherwise use default handling of body -->
<xsl:otherwise>
    <xsl:apply-templates select="*[not((@n='site-home'))]"/>
</xsl:otherwise>

此更改将阻止“最近添加”和“社区视图”的渲染

为了在页面结构的其他位置显示“最近添加的”,我为此创建了一个模板:

<xsl:template name="buildCustomRecent">
    <ul class="list-group-plain" style="list-style: none;">
        <xsl:variable name="countRecent">
            <xsl:value-of select="count(/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*)" />
        </xsl:variable>
        <xsl:for-each select="/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*">
            <xsl:variable name="externalMetadataURL">
                <xsl:text>cocoon:/</xsl:text>
                <xsl:value-of select="@url"/>
                <!-- No options selected, render the full METS document -->
            </xsl:variable>
            <xsl:variable name="title"
                          select="document($externalMetadataURL)//dim:field[@element='title'][not(@qualifier)]"/>
            <xsl:variable name="author"
                          select="document($externalMetadataURL)//dim:field[@element='contributor'][@qualifier='author'][1]/text()"/>
            <xsl:variable name="issue-date"
                          select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
            <xsl:variable name="urlObjId" select="document($externalMetadataURL)//mets:METS/@OBJID"/>

            <li>
                <a>
                    <xsl:attribute name="href">
                        <xsl:value-of select="$urlObjId"/>
                    </xsl:attribute>
                    <xsl:value-of select="$title"/>
                </a>
                <br/>
                <xsl:value-of select="concat($author,' (',$issue-date,')')"/>
                <br/>
            </li>
        </xsl:for-each>
        <xsl:if test="$countRecent=0">
            <xsl:text>No itens to show.</xsl:text>
        </xsl:if>
    </ul>
</xsl:template>

    茧:/


  • 没有要展示的图片。

我在page-structure.xsl中修改了“最近添加的”代码块:

<!-- Otherwise use default handling of body -->
<xsl:otherwise>
    <xsl:apply-templates />
</xsl:otherwise>

据此:

<!-- Otherwise use default handling of body -->
<xsl:otherwise>
    <xsl:apply-templates select="*[not((@n='site-home'))]"/>
</xsl:otherwise>

此更改将阻止“最近添加”和“社区视图”的渲染

为了在页面结构的其他位置显示“最近添加的”,我为此创建了一个模板:

<xsl:template name="buildCustomRecent">
    <ul class="list-group-plain" style="list-style: none;">
        <xsl:variable name="countRecent">
            <xsl:value-of select="count(/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*)" />
        </xsl:variable>
        <xsl:for-each select="/dri:document/dri:body/dri:div/dri:div/dri:referenceSet/*">
            <xsl:variable name="externalMetadataURL">
                <xsl:text>cocoon:/</xsl:text>
                <xsl:value-of select="@url"/>
                <!-- No options selected, render the full METS document -->
            </xsl:variable>
            <xsl:variable name="title"
                          select="document($externalMetadataURL)//dim:field[@element='title'][not(@qualifier)]"/>
            <xsl:variable name="author"
                          select="document($externalMetadataURL)//dim:field[@element='contributor'][@qualifier='author'][1]/text()"/>
            <xsl:variable name="issue-date"
                          select="document($externalMetadataURL)//dim:field[@element='date'][@qualifier='issued'][1]/text()"/>
            <xsl:variable name="urlObjId" select="document($externalMetadataURL)//mets:METS/@OBJID"/>

            <li>
                <a>
                    <xsl:attribute name="href">
                        <xsl:value-of select="$urlObjId"/>
                    </xsl:attribute>
                    <xsl:value-of select="$title"/>
                </a>
                <br/>
                <xsl:value-of select="concat($author,' (',$issue-date,')')"/>
                <br/>
            </li>
        </xsl:for-each>
        <xsl:if test="$countRecent=0">
            <xsl:text>No itens to show.</xsl:text>
        </xsl:if>
    </ul>
</xsl:template>

    茧:/


  • 没有要展示的图片。

Terry,我没有使用java函数,而是使用了
date:year()
函数来比较发行日期是否等于当前年份。当然,我首先使用子字符串
$issuedate
返回4位数字。我注意到
[@rend='recent-submission']
应该是
[@rend='recent-submissions']
我已经将
discovery.xml
中的元数据字段更改为发布日期,而不是访问日期。我的测试条件如下:
,但我的结果是空白的。提前谢谢。我更新了我的帖子,加入了我实际使用的代码。最近的列表未显示,请告知问题所在