Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

This recipe is written for the Manakin (XMLUI) interface supplied with Dspace >= 1.5.0. Compatibility with < 1.5.0 is not guaranteed.

This recipe will turn plain carriage returns/newlines in metadata text into proper HTML paragraph breaks when a simple item record is displayed. The nature of <p/> means that multiple carriage returns in a row will be rendered as a single paragraph break by the browser.

Create a new template, like:

 <xsl:template name="break">
    <xsl:param name="text" select="."/>
    <xsl:choose>
    <xsl:when test="contains($text, '&amp;#xa;')">
       <xsl:value-of select="substring-before($text, '&amp;#xa;')"/>
       <p/>
       <xsl:call-template name="break">
           <xsl:with-param name="text" select="substring-after($text,
 '&amp;#xa;')"/>
       </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
         <xsl:value-of select="$text"/>
    </xsl:otherwise>
    </xsl:choose>
 </xsl:template>

Find or override the template that handles item display, eg.

<xsl:template match="dim:dim" mode="itemSummaryView-DIM">

If you want to render line breaks only for a specific metadata field (dc.description.abstract in this example), make sure you only call the template when that metadata is matched:

<xsl:if test="dim:field[atelement='description' and atqualifier='abstract']">

Then loop through each match and call the 'break' template:

 <xsl:for-each select="dim:field[@element='description' and @qualifier='abstract']">
   <xsl:call-template name="break">
     <xsl:with-param name="text" select="./node()"/>
   </xsl:call-template>
   <xsl:if test="count(following-sibling::dim:field[@element='description' and @qualifier='abstract']) != 0">
     <hr class="metadata-seperator"/>
   </xsl:if>
 </xsl:for-each>

Most of this code is already available in dri2xhtml/structural.xsl, it just needs the 'break' template added and the usual value-of select replaced by the call-template/with-param.

Note: Because this method uses <p/> tags to generate paragraph breaks, the first paragraph of the abstract will be differently formatted to the rest if a <p/> is not inserted before the first call to 'break'.

  • No labels