I'm working in the xsl-file "generate_document_structure.xsl" and a'm not so familiar with this older structure.
My goal in this is to change the writing-mode from lr-tb to rl-tb if the language in the METADATA is FA or AR.
Below a cleaned-up piece of code from the ouputfolder
<?xml version="1.0" encoding="UTF-8"?>
<fctdcl>
<publicationinfo dclselection="SelectedNode">
<props>
<attrblock type="1toN" name="language">
<attrlist>
<attrdesc id="1" name="language"/>
</attrlist>
<attrrec>
<attrval id="1">Default</attrval>
</attrrec>
</attrblock>
</props>
</publicationinfo>
It is a big guess for my how to make the connection to the METADATA if the language is FA. in other words, i'm looking for the wright xpath to the METADATA and select the value of it.
i was thinking in the way like below:
<xsl:variable name="language">
<xsl:value-of select="//*[contains(#class, ' /FCTDocuments/metadata/#language ')]/#content"></xsl:value-of>
</xsl:variable>
<xsl:choose>
<xsl:when test="$language = 'FA'">
<xsl:attribute name="writing-mode">rl-tb</xsl:attribute>
</xsl:when>
</xsl:choose>
I would appreciate it if someone could help me in this
#Toni,
I made some steps with it.
Below my current file.
<xsl:template name="FoT_page-sequence_ContentSequence">
<xsl:choose>
<xsl:when test="not(/FCTDocuments/chapter)">
<fo:page-sequence master-reference="ContentSequence">
<xsl:call-template name="AddHyphenationToSequence"/>
<xsl:call-template name="chapter_header_footer_without_config"/>
<fo:flow flow-name="xsl-region-body" xsl:use-attribute-sets="XSL_Content">
<fo:block id="last-page"/>
</fo:flow>
</fo:page-sequence>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="/FCTDocuments/chapter">
<fo:page-sequence master-reference="ContentSequence" initial-page-number="auto-odd" writing-mode="rl-tb"> <!---->
<xsl:if test="/FCTDocuments/#RSKM-ProductType = 'MM' ">
<xsl:attribute name="initial-page-number">
<xsl:text>1</xsl:text>
</xsl:attribute>
</xsl:if>
<fo:flow flow-name="xsl-region-body" xsl:use-attribute-sets="XSL_Content">
<xsl:if test="count(preceding-sibling::chapter) = 0">
<xsl:if test="$DEBUG = 'true'">
<!-- write debug informations -->
<xsl:comment>
<xsl:text>DEBUG: Starting Content creation</xsl:text>
</xsl:comment>
</xsl:if>
<fo:block>
<fo:marker marker-class-name="DOCUMENTNAME">
<xsl:value-of select="/FCTDocuments/Cover/CoverTitle"/>
</fo:marker>
<fo:marker marker-class-name="DOCUMENTINFO">
<xsl:value-of select="$DOCUMENTINFO"/>
</fo:marker>
</fo:block>
</xsl:if>
<xsl:apply-templates select="."/>
<xsl:if test="count(following-sibling::chapter) = 0">
<fo:block id="last-page"/>
</xsl:if>
</fo:flow>
</fo:page-sequence>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
As we zoom in at the codepart below i added the attribure "writing-mode" in the fo:page-sequence. And after a test it worked fine, But this must only happend when the language is FA
So no i need to make a choose of if statement like test="/FCTDocuments/#RSKM-Language = 'FA'">
how do I manage that if the lang-attribute is FA
<fo:page-sequence master-reference="ContentSequence" initial-page-number="auto-odd" writing-mode="rl-tb"> <!---->
<xsl:if test="/FCTDocuments/#RSKM-ProductType = 'MM' ">
<xsl:attribute name="initial-page-number">
<xsl:text>1</xsl:text>
</xsl:attribute>
</xsl:if>
You initially said you were looking for the right XPath to select your METADATA/metadata, which is why I was asking to see the language code in your source XML.
I am guessing that this is what you want:
<xsl:if test="/FCTDocuments/#RSKM-Language = 'FA'">
<xsl:attribute name="writing-mode">rl</xsl:attribute>
</xsl:if>
You can then omit the writing-mode property on the fo:page-sequence since the default writing-mode value is lr-tb.
Related
I have this code:
<!--Display the name of the brother assigned-->
<xsl:template match="Name | PrayerOpen | PrayerEnd">
<td class="cellName">
<xsl:choose>
<xsl:when test="//MeetingWorkBook/Settings/ForeignGroupMode='1' and (
../#BookmarkId='2' or ../../#BookmarkId='2' or
../../../#BookmarkId='2'or ../../../../#BookmarkId='2' or
../#BookmarkId='4' or ../../#BookmarkId='4' or
../../../#BookmarkId='4' or ../../../../#BookmarkId='4' or
self::PrayerOpen or self::PrayerEnd)">
<em><xsl:value-of select ="//Labels/MainHall"/></em>
</xsl:when>
<xsl:when test="//MeetingWorkBook/Settings/ForeignGroupMode='1' and .='' and self::Name">
<em><xsl:value-of select ="//Labels/MainHall"/></em>
</xsl:when>
<xsl:when test="#Duplicate=1">
<span class="textDuplicate">
<xsl:value-of select="."/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
It works fine. I have a series of paths so that I can find the correct node which has the BookmarkId attribute. Can this code be simplified?
Basically, based on the context of the current node I want to walk up the parents until it hits the Meeting node which is the one with the attribute.
Example XML
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="Workbook-S-140-PublicTalk-WatchtowerStudy-ServiceTalk-FGroup-v2.xsl"?>
<MeetingWorkBook>
<Meeting BookmarkId="0" PageBreak="0" NumberClasses="1" SpecialEvent="0">
<PrayerOpen>Name 1</PrayerOpen>
<TFGW NumberClasses="1">
<TFGWItem>
<Name>Name 2</Name>
</TFGWItem>
<TFGWItem>
<Name>Name 3</Name>
</TFGWItem>
</TFGW>
<AYFM NumberClasses="1">
<Teaching>
<Name>Name 4</Name>
</Teaching>
</AYFM>
<LAC CircuitVisit="0">
<LACItem>
<Name>Name 5</Name>
</LACItem>
<PrayerEnd>Name 6</PrayerEnd>
</LAC>
</Meeting>
</MeetingWorkBook>
Based on the advice in the comments I have ended up using the ancestor call. So my template now looks like this:
<!--Display the name of the brother assigned-->
<xsl:template match="Name | PrayerOpen | PrayerEnd">
<td class="cellName">
<xsl:choose>
<xsl:when test="//MeetingWorkBook/Settings/ForeignGroupMode='1' and (
ancestor::Meeting[#BookmarkId='2'] or
ancestor::Meeting[#BookmarkId='4'] or self::PrayerOpen or self::PrayerEnd)">
<em><xsl:value-of select ="//Labels/MainHall"/></em>
</xsl:when>
<xsl:when test="//MeetingWorkBook/Settings/ForeignGroupMode='1' and .='' and self::Name">
<em><xsl:value-of select ="//Labels/MainHall"/></em>
</xsl:when>
<xsl:when test="#Duplicate=1">
<span class="textDuplicate">
<xsl:value-of select="."/>
</span>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:template>
I am trying to display the thumbnails from harvested items. The settings I have for the harvesting options is Harvest metadata and references to bitstreams (requires ORE support). When looking for the code on how DSpace displays the filenames and file sizes of the bitstreams of the harvested items in simple view, I found that in https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L375-L378
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM" />
</xsl:when>
and for the full item record view in https://github.com/DSpace/DSpace/blob/dspace-6.1/dspace-xmlui-mirage2/src/main/webapp/xsl/aspect/artifactbrowser/item-view.xsl#L81-L84.
<!-- Special case for handling ORE resource maps stored as DSpace bitstreams -->
<xsl:when test="./mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="./mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemDetailView-DIM" />
</xsl:when>
So it seems that code found in item-view.xsl is calling the template match found in ORE.xsl.
Now, looking at a sample mets.xml file of a harvested item specifically in //mets:fileSec/mets:fileGrp[#USE='ORE'], we can see that it is referencing the ORE.xml in /bitstream/handle/10862/3360/ORE.xml.
<mets:fileSec>
<mets:fileGrp USE="ORE">
<mets:file GROUPID="group_file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUM="7afebcfcf393395503377219395e3926" MIMETYPE="text/xml" SIZE="4137" ID="file_f148a8ad-b7ad-49fe-8b4b-0d3893d2c351" CHECKSUMTYPE="MD5">
<mets:FLocat LOCTYPE="URL" xlink:href="/bitstream/handle/10862/3360/ORE.xml?sequence=1&isAllowed=y" xlink:type="locator" xlink:title="ORE.xml"/>
</mets:file>
</mets:fileGrp>
</mets:fileSec>
Based on the template match found in ORE.xsl, we can see that the file names and file size was generated from this code:
<xsl:template match="mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[#LOCTYPE='URL']//#*[local-name(.)='href'],$context-path))"/>
<div class="item-page-field-wrapper table">
<h5>
<i18n:text>xmlui.dri2xhtml.METS-1.0.item-files-viewOpen</i18n:text>
</h5>
<xsl:for-each select="document($AtomMapURL)/atom:entry/atom:link[#rel='http://www.openarchives.org/ore/terms/aggregates']">
<xsl:variable name="link_href" select="#href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href][dcterms:description='ORIGINAL']
or not(/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href])">
<xsl:call-template name="itemSummaryView-DIM-file-section-entry">
<xsl:with-param name="href" select="#href" />
<xsl:with-param name="mimetype" select="#type" />
<xsl:with-param name="label-1" select="'title'" />
<xsl:with-param name="label-2" select="'title'" />
<xsl:with-param name="title" select="#title" />
<xsl:with-param name="label" select="#title" />
<xsl:with-param name="size" select="#length" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
</div>
</xsl:template>
Viewing the /bitstream/handle/10862/3360/ORE.xml, we can see that aside from the ORIGINAL bundle, the TEXT and THUMBNAIL bundles were also captured when it was harvested.
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf" length="2310365" rel="http://www.openarchives.org/ore/terms/aggregates" title="ediblecrustacea.pdf" type="application/pdf"/>
<atom:link href="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf" length="177699" rel="http://www.openarchives.org/ore/terms/aggregates" title="edible-crust-errata.pdf" type="application/pdf"/>
<oreatom:triples>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="http://hdl.handle.net/10862/152/ore.xml#atom">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceItem"/>
<dcterms:modified>2011-06-07T06:45:26Z</dcterms:modified>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/35/edible-crust-errata.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/36/ediblecrustacea.pdf.txt">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>TEXT</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/1/ediblecrustacea.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/4/edible-crust-errata.pdf">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>ORIGINAL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/32/ediblecrustacea.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="https://repository.seafdec.org.ph/bitstream/10862/152/33/edible-crust-errata.pdf.jpg">
<rdf:type rdf:resource="http://www.dspace.org/objectModel/DSpaceBitstream"/>
<dcterms:description>THUMBNAIL</dcterms:description>
</rdf:Description>
</oreatom:triples>
Now my goal is to capture and reuse the url found in /atom:entry/oreatom:triples/rdf:Description[#rdf:about][dcterms:description='THUMBNAIL'] and make it as the src of the thumbnail found in the code for the itemSummaryView-DIM-thumnail and mets:filetemplate, sort of hotlinking to the original thumbnail. By the way, the Files in this item view is not that nice anyway so...
With regards to the displaying of thumbnail in simple view, I'm thinking of having an <xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']"> in the itemSummaryView-DIM-thumbnail template ie:
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file[#GROUPID=../../mets:fileGrp[#USE='CONTENT']/mets:file[#GROUPID=../../mets:fileGrp[#USE='THUMBNAIL']/mets:file/#GROUPID][1]/#GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file[#GROUPID=../../mets:fileGrp[#USE='CONTENT']/mets:file[#GROUPID=../../mets:fileGrp[#USE='THUMBNAIL']/mets:file/#GROUPID][1]/#GROUPID]/mets:FLocat[#LOCTYPE='URL']/#xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file/mets:FLocat[#LOCTYPE='URL']/#xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Checking if Thumbnail is restricted and if so, show a restricted image -->
<xsl:choose>
<xsl:when test="contains($src,'isAllowed=n')"/>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
My problem now is that I don't know how to reference the url for the thumbnail in the ORE.xml file. I noticed also that the name and file size were extracted from the /atom:entry/atom:link[#rel='http://www.openarchives.org/ore/terms/aggregates'] based from the ORE.xsl code above.
Thanks in advance!
UPDATE
Here's what I did:
I modify the [dspace]/config/crosswalks/oai/metadataFormats/ore.xsl of the source server such that it will expose the thumbnails in the <atom:link rel="http://www.openarchives.org/ore/terms/aggregates"> portion of OAI output when using ore as the metadata format, but I have to clean the cache of oai and do a full reimport of OAI in the source server. Also, I have to reset and import the harvest from the harvesting server to include the new generated ORE.xml files. The modification I did was to change line number 67 of ore.xsl from
<xsl:if test="doc:field[#name='name']/text() = 'ORIGINAL'">
into:
<xsl:if test="doc:field[#name='name']/text() = 'ORIGINAL' or doc:field[#name='name']/text() = 'THUMBNAIL'">
Then in item-view.xsl, I included this line in the <xsl:template name="itemSummaryView-DIM-thumbnail">:
Then, in [dspace]/webapps/xmlui/themes/Mirage2/xsl/aspect/artifactbrowser/ORE.xsl I include these lines:
<xsl:template match="mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[#LOCTYPE='URL']//#*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/atom:link[#rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="atom:link[#rel='http://www.openarchives.org/ore/terms/aggregates']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="link_href" select="#href"/>
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1]
or not(/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href])">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="#href"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
This worked except that in cases where there are multiple thumbnails in the source item, it will also show more than one thumbnails even though I have in my test condition <xsl:if test="/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href][dcterms:description='THUMBNAIL' and position() = 1] or not(/atom:entry/oreatom:triples/rdf:Description[#rdf:about=$link_href])">. See screenshot below:
Also, I would rather not modify the ore.xsl in the crosswalk directory of the source server hence this post: Extract attribute value if child node contains this text
UPDATE 2 - Thumbnail is now displayed in simple item view
What I did:
In <xsl:template name="itemSummaryView-DIM-thumbnail">, I inserted the code below after line# 195:
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
Then, I added this templates in ORE.xsl:
<xsl:template match="mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[#LOCTYPE='URL']//#*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img class="img-thumbnail" alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(#rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/#rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
My harvested item is now displaying the thumbnail in item summary view:
It would really be great if I can also make the thumbnails display in the item list and search results but for now, I can't figure out how to match and select the thumbnail url. I don't know how to reference them from within the <xsl:template match="mets:fileSec" mode="artifact-preview"> template.
For my future reference, this is what I have made to show the thumbnails for harvested items.
This answer is based on DSpace 5x Mirage2 Theme but it can also be applied to DSpace 6x Mirage2.
In item-view.xsl, locate the <xsl:template name="itemSummaryView-DIM-thumbnail"> block and then insert this code:
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
before the <xsl:otherwise> block. Complete template block below:
<xsl:template name="itemSummaryView-DIM-thumbnail">
<div class="thumbnail">
<xsl:choose>
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']">
<xsl:variable name="src">
<xsl:choose>
<xsl:when test="/mets:METS/mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file[#GROUPID=../../mets:fileGrp[#USE='CONTENT']/mets:file[#GROUPID=../../mets:fileGrp[#USE='THUMBNAIL']/mets:file/#GROUPID][1]/#GROUPID]">
<xsl:value-of
select="/mets:METS/mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file[#GROUPID=../../mets:fileGrp[#USE='CONTENT']/mets:file[#GROUPID=../../mets:fileGrp[#USE='THUMBNAIL']/mets:file/#GROUPID][1]/#GROUPID]/mets:FLocat[#LOCTYPE='URL']/#xlink:href"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of
select="//mets:fileSec/mets:fileGrp[#USE='THUMBNAIL']/mets:file/mets:FLocat[#LOCTYPE='URL']/#xlink:href"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<img alt="Thumbnail">
<xsl:attribute name="src">
<xsl:value-of select="$src"/>
</xsl:attribute>
</img>
</xsl:when>
<xsl:when test="//mets:fileSec/mets:fileGrp[#USE='ORE']">
<xsl:apply-templates select="//mets:fileSec/mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail" />
</xsl:when>
<xsl:otherwise>
<img alt="Thumbnail">
<xsl:attribute name="data-src">
<xsl:text>holder.js/100%x</xsl:text>
<xsl:value-of select="$thumbnail.maxheight"/>
<xsl:text>/text:No Thumbnail</xsl:text>
</xsl:attribute>
</img>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:template>
Then edit ORE.xsl and insert the code below just before the </xsl:stylesheet> ending tag.
<xsl:template match="mets:fileGrp[#USE='ORE']" mode="itemSummaryView-DIM-thumbnail">
<xsl:variable name="AtomMapURL" select="concat('cocoon:/',substring-after(mets:file/mets:FLocat[#LOCTYPE='URL']//#*[local-name(.)='href'],$context-path))"/>
<xsl:apply-templates select="document($AtomMapURL)/atom:entry/oreatom:triples" mode="itemSummaryView-DIM-thumbnail"/>
</xsl:template>
<xsl:template match="oreatom:triples" mode="itemSummaryView-DIM-thumbnail">
<xsl:if test="/atom:entry/oreatom:triples/rdf:Description[dcterms:description='THUMBNAIL']
or not(/atom:entry/oreatom:triples/rdf:Description)">
<img alt="Thumbnail" class="img-responsive">
<xsl:attribute name="src">
<xsl:value-of select="rdf:Description[boolean(#rdf:about) and
.//dcterms:description[. = 'THUMBNAIL']][1]/#rdf:about"/>
</xsl:attribute>
</img>
</xsl:if>
</xsl:template>
To show the thumbnails in item list, edit common.xsl and locate this code:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL</xsl:text>
and change it to:
<xsl:text>?sections=dmdSec,fileSec&fileGrpTypes=THUMBNAIL,ORE</xsl:text>
To show thumbnails in search results, locate that same line of code above in the file discovery.xsl found under [dspace-src]/dspace/modules/xmlui-mirage2/src/main/webapp/themes/Mirage2/xsl/aspect/discovery directory and modify it just like in the common.xsl file.
All file modifications in this answer are made under the [dspace-src]dspace/modules directory.
Example of this code in action can be found here: SEAFDEC External Publications
I have an XML tag which has names in it e.g. H&M. The requirement is that it should output as H & M. I am unable to achieve this yet.
None of the escape characters, & or & worked for me. Here's what worked:
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:choose>
<xsl:when test="contains($text, '&')">
<xsl:value-of select="substring-before($text,'&')"/>
<xsl:text disable-output-escaping="yes"><![CDATA[&]]></xsl:text>
<xsl:value-of select="substring-after($text,'&')"/>
</xsl:when>
<xsl:when test="contains($text, ''')">
<xsl:value-of select="substring-before($text,''')"/>
<xsl:text disable-output-escaping="yes"><![CDATA[']]></xsl:text>
<xsl:value-of select="substring-after($text,''')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
And then call template:
<Nm>
<xsl:variable name="suppNm">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="Payee/Name" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$suppNm" />
</Nm>
If anyone knows a better solution, would be very interested to know. I am a total beginner to XSL.
I need to replace a single quote to double quotes.
For example: input = Ram's
So i need a output as Ram''s
How to do in xslt 1.0? Please help me!
Its working for me!
<xsl:template match="name">
<xsl:copy>
<xsl:call-template name="replace">
<!-- Here getting the replaced values -->
<xsl:with-param name="text" select="."/>
</xsl:call-template>
</xsl:copy>
</xsl:template>
<xsl:template name="replace">
<xsl:param name="text"/>
<xsl:param name="searchString">'</xsl:param>
<xsl:param name="replaceString">''</xsl:param>
<xsl:choose>
<xsl:when test="contains($text,$searchString)">
<xsl:value-of select="substring-before($text,$searchString)"/>
<xsl:value-of select="$replaceString"/>
<!-- recursive call -->
<xsl:call-template name="replace">
<xsl:with-param name="text" select="substring-after($text,$searchString)"/>
<xsl:with-param name="searchString" select="$searchString"/>
<xsl:with-param name="replaceString" select="$replaceString"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Have the following template that I use with xsl:call-template, but I need to use it to replace a ~ with <br />. I can get it to work with none HTML replacements but not when I try to use <br /> or 
 or
. Any suggestions:
<xsl:template name="replace-substring">
<xsl:param name="original"/>
<xsl:param name="substring"/>
<xsl:param name="replacement" select="''"/>
<xsl:variable name="first">
<xsl:choose>
<xsl:when test="contains($original, $substring)" >
<xsl:value-of select="substring-before($original, $substring)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$original"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="middle">
<xsl:choose>
<xsl:when test="contains($original, $substring)">
<xsl:value-of select="$replacement" />
</xsl:when>
<xsl:otherwise>
<xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="last">
<xsl:choose>
<xsl:when test="contains($original, $substring)">
<xsl:choose>
<xsl:when test="contains(substring-after($original, $substring),
$substring)">
<xsl:call-template name="replace-substring">
<xsl:with-param name="original">
<xsl:value-of select="substring-after($original, $substring)"/>
</xsl:with-param>
<xsl:with-param name="substring">
<xsl:value-of select="$substring"/>
</xsl:with-param>
<xsl:with-param name="replacement">
<xsl:value-of select="$replacement"/>
</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after($original, $substring)" />
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:text></xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat($first, $middle, $last)"/>
</xsl:template>
It's hard to tell what's going on with the first, middle, and last variables but you should be able to just use a literal <br/> in your param...
XML
<test>one~two~three</test>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="test">
<xsl:copy>
<xsl:call-template name="replace-char"/>
</xsl:copy>
</xsl:template>
<xsl:template name="replace-char">
<xsl:param name="char" select="'~'"/>
<xsl:param name="replacement"><br/></xsl:param>
<xsl:param name="string" select="."/>
<xsl:variable name="remaining" select="substring-after($string,$char)"/>
<xsl:value-of select="substring-before(concat($string,$char),$char)"/>
<xsl:if test="contains($string,$char)">
<xsl:copy-of select="$replacement"/>
</xsl:if>
<xsl:if test="$remaining">
<xsl:call-template name="replace-char">
<xsl:with-param name="string" select="$remaining"/>
<xsl:with-param name="char" select="$char"/>
<xsl:with-param name="replacement" select="$replacement"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Output
<test>one<br/>two<br/>three</test>