Skip to content

Commit b17bc8b

Browse files
committed
MIR-1566 Improve metadata output
1 parent 8149f72 commit b17bc8b

File tree

1 file changed

+58
-29
lines changed

1 file changed

+58
-29
lines changed

mir-module/src/main/resources/xsl/mir-mods-utils.xsl

Lines changed: 58 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,10 @@
5151
</xsl:choose>
5252
</xsl:variable>
5353

54-
<xsl:variable name="affiliation" select="mods:affiliation[not(@*)]" />
55-
<xsl:variable name="affiliation-ror" select="mods:affiliation[contains(@authorityURI, '//ror.org')]" />
54+
<xsl:variable name="affiliations" select="mods:affiliation" />
5655
<xsl:variable name="personNodeId" select="generate-id(.)"/>
5756
<xsl:variable name="personName"><xsl:apply-templates select="." mode="nameString"/></xsl:variable>
58-
<xsl:if test="count($nameIdentifiers) &gt; 0 or string-length($affiliation) &gt; 0">
57+
<xsl:if test="count($nameIdentifiers) &gt; 0 or count($affiliations) &gt; 0">
5958
<!-- This content will be inserted as popover-->
6059
<div id="{$personNodeId}-content" class="d-none">
6160
<dl>
@@ -71,40 +70,70 @@
7170
</dd>
7271
</xsl:for-each>
7372
</xsl:if>
74-
<xsl:if test="count($affiliation) &gt; 0 or $affiliation-ror">
75-
<dt>
76-
<xsl:value-of select="mcri18n:translate('mir.affiliation')"/>
77-
</dt>
78-
<dd>
79-
<xsl:for-each select="$affiliation">
80-
<div class="mir-affiliation-plain" lang="{$CurrentLang}">
81-
<xsl:value-of select="text()"/>
82-
</div>
83-
</xsl:for-each>
84-
85-
<xsl:for-each select="$affiliation-ror[@valueURI]">
86-
<xsl:sort select="@valueURI"/>
87-
<div class="mir-affiliation-ror">
88-
<a href="https://ror.org/" alt="ROR logo">
89-
<img src="{$WebApplicationBaseURL}images/ror/ror-icon-rgb-transparent.svg"
90-
class="pe-1 mir-ror-logo"/>
91-
</a>
92-
<a class="mir-ror-link" href="{@valueURI}">
93-
<xsl:value-of select="@valueURI"/>
94-
</a>
95-
</div>
96-
</xsl:for-each>
97-
</dd>
98-
</xsl:if>
73+
<xsl:apply-templates select="$affiliations">
74+
<xsl:sort select="boolean(@authority)" data-type="number" order="ascending"/>
75+
<xsl:sort select="@valueURI" data-type="text" order="ascending"/>
76+
</xsl:apply-templates>
9977
</dl>
10078
</div>
10179
</xsl:if>
10280
<a href="{concat($ServletsBaseURL,'solr/mods_nameIdentifier?q=',encoder:encode($query),'&amp;owner=',encoder:encode(concat('createdby:',$owner)))}"><xsl:value-of select="$personName" /></a>
103-
<xsl:if test="count($nameIdentifiers) &gt; 0 or string-length($affiliation) &gt; 0">
81+
<xsl:if test="count($nameIdentifiers) &gt; 0 or string-length($affiliations) &gt; 0">
10482
<!-- class personPopover triggers the javascript popover code -->
10583
<a id="{$personNodeId}" class="personPopover" title="{mcri18n:translate('mir.details.personpopover.title')}">
10684
<span class="fa fa-info-circle"/>
10785
</a>
10886
</xsl:if>
10987
</xsl:template>
88+
89+
<xsl:template match="mods:affiliation[not(@*)]">
90+
<div class="mir-affiliation-plain">
91+
<xsl:value-of select="text()"/>
92+
</div>
93+
</xsl:template>
94+
95+
<xsl:template match="mods:affiliation[@authority]">
96+
<xsl:param name="logo-uri" select="''" />
97+
<xsl:param name="type" select="@authority" />
98+
99+
<xsl:variable name="logo-uri-val">
100+
<xsl:choose>
101+
<xsl:when test="$logo-uri != ''">
102+
<xsl:value-of select="$logo-uri"/>
103+
</xsl:when>
104+
<xsl:otherwise>
105+
<xsl:call-template name="resolve-affiliation-logo-uri">
106+
<xsl:with-param name="authority" select="@authority"/>
107+
</xsl:call-template>
108+
</xsl:otherwise>
109+
</xsl:choose>
110+
</xsl:variable>
111+
<xsl:variable name="type-val" select="
112+
translate($type,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')
113+
" />
114+
115+
<div class="mir-affiliation-{$type-val}">
116+
<xsl:if test="$logo-uri-val != ''">
117+
<a href="{@authorityURI}">
118+
<img src="{$logo-uri-val}" class="pe-1 mir-{$type-val}-logo" alt="{@authority} logo" />
119+
</a>
120+
</xsl:if>
121+
<a class="mir-{$type-val}-link" href="{@valueURI}">
122+
<xsl:value-of select="@valueURI"/>
123+
</a>
124+
</div>
125+
</xsl:template>
126+
127+
<xsl:template name="resolve-affiliation-logo-uri">
128+
<xsl:param name="authority" />
129+
<xsl:choose>
130+
<xsl:when test="$authority = 'ROR'">
131+
<xsl:value-of select="concat($WebApplicationBaseURL, 'images/ror/ror-icon-rgb-transparent.svg')" />
132+
</xsl:when>
133+
<xsl:otherwise>
134+
<xsl:value-of select="''" />
135+
</xsl:otherwise>
136+
</xsl:choose>
137+
</xsl:template>
138+
110139
</xsl:stylesheet>

0 commit comments

Comments
 (0)