So, it turns out to be pretty simple when you know what you're doing:
1) Add confman namespace and "confman" to exclude-result-prefixes.
<xsl:stylesheet
...
xmlns:confman="org.dspace.core.ConfigurationManager"
exclude-result-prefixes="... confman">
2) Add this simple template to process Solr result. More complex date
formatting can be done easily in XSLT 2.0
<http://www.w3.org/TR/xslt20/#format-date>, however Cocoon still uses
XSLT 1.0. It is currently also possible to call Java functions to do
date formatting.
<xsl:template match="/response/result/doc/date" mode="lastItem">
Last item was imported: <xsl:value-of
select="substring(text(), 1, 10)"/>
</xsl:template>
3) Add the following code to the place where you want the resulting
text to appear:
<xsl:variable name="solr-search-url"
select="confman:getProperty('discovery', 'search.server')"/>
<xsl:apply-templates select="document(concat($solr-search-url,
'/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc&rows=1&fl=dc.date.accessioned_dt&omitHeader=true'))"
mode="lastItem"/>
For example, to add it after the list of Recent items in Mirage,
override its template like this:
<xsl:template match="dri:referenceSet[@type = 'summaryList' and
@n='site-last-submitted']" priority="2">
<xsl:apply-templates select="dri:head"/>
<!-- Here we decide whether we have a hierarchical list or a
flat one -->
<xsl:choose>
<xsl:when
test="descendant-or-self::dri:referenceSet/@rend='hierarchy' or
ancestor::dri:referenceSet/@rend='hierarchy'">
<ul>
<xsl:apply-templates
select="*[not(name()='head')]" mode="summaryList"/>
</ul>
</xsl:when>
<xsl:otherwise>
<ul class="ds-artifact-list">
<xsl:apply-templates
select="*[not(name()='head')]" mode="summaryList"/>
</ul>
</xsl:otherwise>
</xsl:choose>
<xsl:variable name="solr-search-url"
select="confman:getProperty('discovery', 'search.server')"/>
<xsl:apply-templates select="document(concat($solr-search-url,
'/select?q=search.resourcetype:2&sort=dc.date.accessioned_dt%20desc&rows=1&fl=dc.date.accessioned_dt&omitHeader=true'))"
mode="lastItem"/>
</xsl:template>
Just remember that this requires Discovery. I tested it in DSpace 1.8,
it may work in 1.7, too.
While experimenting with this I also prepared a short DSpace Solr
tutorial with examples. Hopefully, the page should appear here later
today (someone has to create it for me first, I don't have the right):
https://wiki.duraspace.org/display/DSPACE/Solr
Regards,
~~helix84
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
DSpace-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-tech