summaryrefslogtreecommitdiff
path: root/endnote-to-dbxml.xsl
blob: 8a921e457f1b80174651fb5428102c61ebe06d06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:exsl="http://exslt.org/common"
	extension-element-prefixes="exsl">

	<xsl:key name="author" match="author" use="." />

	<xsl:output method="xml" indent="yes" encoding="UTF-8"  />

	<xsl:include href="util.xsl"/>

	<xsl:template match="record">
		<xsl:param name="authors"/>

		<publication>
			<uid>
				<xsl:value-of select="rec-number" />
			</uid>
			<title>
				<xsl:apply-templates select="titles/title" mode="copy-html" />
			</title>
			<secondary_title>
				<xsl:apply-templates select="titles/secondary-title" mode="copy-html" />
			</secondary_title>
			<full_title>
				<xsl:apply-templates select="periodical/full-title" mode="copy-html" />
			</full_title>
			<type>
				<xsl:value-of select="ref-type/@name" />
			</type>
			<year>
				<xsl:value-of select="dates/year" />
			</year>

			<authors>
				<xsl:for-each select="contributors/authors/author">
					<xsl:if test="position() &gt; 1">
						<xsl:text>,</xsl:text>
					</xsl:if>
					<xsl:value-of select="exsl:node-set($authors)/tx_likat_pubs_domain_model_authors/author[name=current()]/uid" />
				</xsl:for-each>
			</authors>
		</publication>
	</xsl:template>

	<xsl:template match="records">
		<xsl:param name="authors"/>
		<tx_likat_pubs_domain_model_publications>
			<xsl:apply-templates select="record">
				<xsl:with-param name="authors">
					<xsl:call-template name="authors" />
				</xsl:with-param>
			</xsl:apply-templates>
		</tx_likat_pubs_domain_model_publications>
	</xsl:template>

	<xsl:template match="author">
		<author>
			<xsl:variable name="pos" select="position()"/>
			<uid><xsl:value-of select="$pos"/></uid>
			<name><xsl:value-of select="." /></name>
		</author>
	</xsl:template>


	<xsl:template name="authors">
		<tx_likat_pubs_domain_model_authors>
			<xsl:apply-templates select="//author[generate-id() = generate-id(key('author', .)[1])]"/>
		</tx_likat_pubs_domain_model_authors>
	</xsl:template>

	<xsl:template match="/">
		<db>
			<xsl:apply-templates select="xml/records"/>
			<xsl:call-template name="authors" />
		</db>
	</xsl:template>

</xsl:stylesheet>