|
68 | 68 | </p>
|
69 | 69 | </xsl:template>
|
70 | 70 |
|
| 71 | + <xsl:function name="doc:get-references"> |
| 72 | + <xsl:param name="context" /> |
| 73 | + <references> |
| 74 | + <xsl:for-each-group select="$context//ref" group-by="concat(./@doi, '|', ./@arxiv, '|', ./@isbn)"> |
| 75 | + <xsl:copy-of select="." /> |
| 76 | + </xsl:for-each-group> |
| 77 | + </references> |
| 78 | + </xsl:function> |
| 79 | + |
71 | 80 | <xsl:template match="ref[@doi]">
|
72 |
| - <xsl:variable name="maxauthors" select="2" /> |
| 81 | + <xsl:variable name="references" select="doc:get-references(/root)" /> |
| 82 | + <xsl:variable name="doi" select="./@doi" /> |
73 | 83 | <xsl:variable name="safedoi" select="replace(replace(replace(./@doi, '/', '_'), '\(', '_'), '\)', '_')" />
|
74 |
| - <xsl:variable name="ref" select="document(concat('./tmp/ref_', $safedoi, '.xml'))" /> |
75 |
| - |
76 |
| - <a href="#ref-{$safedoi}" class="reference"> |
77 |
| - (<xsl:for-each select="$ref//contributors/person_name[@contributor_role='author']"> |
78 |
| - <xsl:if test="not(position() > $maxauthors)"> |
79 |
| - <xsl:value-of select="./given_name" /> <xsl:value-of select="./surname" /> |
80 |
| - <xsl:if test="position() != last() and not(position() >= $maxauthors) ">, </xsl:if> |
81 |
| - </xsl:if> |
82 |
| - </xsl:for-each> |
83 |
| - <xsl:if test="count($ref//contributors/person_name[@contributor_role='author']) > $maxauthors"> |
84 |
| - et al. |
85 |
| - </xsl:if> |
86 |
| -  <xsl:value-of select="$ref/doi_records/doi_record/crossref/journal/journal_article/publication_date[1]/year" />) |
87 |
| - </a> |
| 84 | + [<a href="#ref-{$safedoi}" class="reference"><xsl:value-of select="count($references//ref[@doi=$doi]/preceding-sibling::*)+1" /></a>] |
88 | 85 | </xsl:template>
|
89 |
| - |
| 86 | + |
90 | 87 | <xsl:template match="ref[@arxiv]">
|
91 |
| - <xsl:variable name="maxauthors" select="2" /> |
| 88 | + <xsl:variable name="references" select="doc:get-references(/root)" /> |
| 89 | + <xsl:variable name="arxiv" select="./@arxiv" /> |
92 | 90 | <xsl:variable name="safearxiv" select="replace(replace(replace(./@arxiv, '/', '_'), '\(', '_'), '\)', '_')" />
|
93 |
| - <xsl:variable name="ref" select="(document(concat('./tmp/ref_', $safearxiv, '.xml'))//atom:entry)[1]" /> |
94 |
| - <a href="#ref-{$safearxiv}" class="reference"> |
95 |
| - (<xsl:for-each select="$ref//atom:author"> |
96 |
| - <xsl:if test="not(position() > $maxauthors)"> |
97 |
| - <xsl:value-of select="./atom:name" /> |
98 |
| - <xsl:if test="position() != last() and not(position() >= $maxauthors) ">, </xsl:if> |
99 |
| - </xsl:if> |
100 |
| - </xsl:for-each> |
101 |
| - <xsl:if test="count($ref//atom:author) > $maxauthors"> |
102 |
| - et al. |
103 |
| - </xsl:if> |
104 |
| -  <xsl:value-of select="substring(($ref//atom:published)[1], 1, 4)" />) |
105 |
| - </a> |
| 91 | + [<a href="#ref-{$safearxiv}" class="reference"><xsl:value-of select="count($references//ref[@arxiv=$arxiv]/preceding-sibling::*)+1" /></a>] |
106 | 92 | </xsl:template>
|
107 | 93 |
|
108 | 94 | <xsl:template match="ref[@isbn]">
|
109 |
| - <xsl:variable name="maxauthors" select="2" /> |
110 |
| - <xsl:variable name="ref" select="document(concat('./tmp/ref_', ./@isbn, '.xml'))//fn:map[@key='volumeInfo'][1]" /> |
111 |
| - |
112 |
| - <a href="#ref-{./@isbn}" class="reference"> |
113 |
| - (<xsl:for-each select="$ref//fn:array[@key='authors']/fn:string[position() <= $maxauthors]"> |
114 |
| - <xsl:value-of select="." /> |
115 |
| - <xsl:if test="position() != last() and not(position() >= $maxauthors) ">, </xsl:if> |
116 |
| - </xsl:for-each> |
117 |
| - <xsl:if test="count($ref//fn:array[@key='authors']/fn:string) > $maxauthors"> |
118 |
| - et al. |
119 |
| - </xsl:if> |
120 |
| -  <xsl:value-of select="substring(($ref//fn:string[@key='publishedDate'])[1], 1, 4)" />) |
121 |
| - </a> |
| 95 | + <xsl:variable name="references" select="doc:get-references(/root)" /> |
| 96 | + <xsl:variable name="isbn" select="./@isbn" /> |
| 97 | + [<a href="#ref-{./@isbn}" class="reference"><xsl:value-of select="count($references//ref[@isbn=$isbn]/preceding-sibling::*)+1" /></a>] |
122 | 98 | </xsl:template>
|
123 | 99 |
|
124 | 100 | <xsl:template name="ref-description">
|
|
0 commit comments