Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet version="1.0"
3
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nxsl="http://www.w3.org/1999/XSL/TransformXX"
4
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5

    
6
	<xsl:output omit-xml-declaration="yes" method="xml"
7
		encoding="UTF-8" />
8
	<xsl:namespace-alias stylesheet-prefix="nxsl"
9
		result-prefix="xsl" />
10

    
11
	<xsl:param name="format" />
12

    
13
	<xsl:template match="/">
14
		<xsl:apply-templates select="//LAYOUT" />
15
	</xsl:template>
16

    
17
	<xsl:template match="LAYOUT">
18
		<nxsl:stylesheet version="1.0"
19
			xmlns:dr="http://www.driver-repository.eu/namespace/dr" xmlns:dc="http://purl.org/dc/elements/1.1/"
20
			xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions"
21
			xmlns:exsl="http://exslt.org/common"
22
      extension-element-prefixes="exsl">
23

    
24
			<nxsl:output version="1.0" omit-xml-declaration="yes"
25
				method="xml" encoding="UTF8" />
26

    
27
			<nxsl:variable name="format">
28
				<xsl:value-of select="$format" />
29
			</nxsl:variable>
30

    
31
			<nxsl:template match="/">
32
				<indexRecord>
33
					<indexRecordIdentifier>
34
						<nxsl:value-of select="//dri:objIdentifier" />
35
					</indexRecordIdentifier>
36
					<targetFields>
37
						<nxsl:if test="$format != 'DMF' or string(//dc:title)">
38
							<nxsl:if test="count(//*[local-name()='metadata']/*) &gt; 0">
39
								<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']" />
40
							</nxsl:if>		
41
						</nxsl:if>
42
					</targetFields>
43
					<result>
44
						<header>
45
							<dri:objIdentifier>
46
								<nxsl:value-of select="//dri:objIdentifier" />
47
							</dri:objIdentifier>
48
							<dri:repositoryId>
49
								<nxsl:value-of select="//dri:repositoryId" />
50
							</dri:repositoryId>
51
							<dri:dateOfCollection>
52
								<nxsl:value-of select="//dri:dateOfCollection" />
53
							</dri:dateOfCollection>
54
							<xsl:apply-templates select="FIELDS/FIELD"
55
								mode="header" />
56
						</header>
57
						<metadata>
58
							<xsl:apply-templates select="FIELDS/FIELD"
59
								mode="result" />
60
						</metadata>
61
					</result>
62
				</indexRecord>
63
			</nxsl:template>
64
		</nxsl:stylesheet>
65
	</xsl:template>
66

    
67
	<xsl:template match="FIELD[@indexable='true']">
68
		<xsl:choose>
69
			<!-- 
70
			<xsl:when test="@name = 'description'">
71
				<nxsl:for-each select="{@xpath}">
72
					<xsl:element name="{@name}">
73
						<nxsl:value-of select="substring(.,1,210)" />
74
					</xsl:element>
75
				</nxsl:for-each>
76
			</xsl:when>
77
			 -->
78
			<xsl:when test="@constant">
79
				<xsl:element name="{@name}">
80
					<xsl:value-of select="@constant" />
81
				</xsl:element>
82
			</xsl:when>
83
			<xsl:when test="@value and not(@xpath)">
84
				<nxsl:element name="{@name}">
85
					<nxsl:value-of select="{@value}" />
86
				</nxsl:element>
87
			</xsl:when>
88
			<xsl:otherwise>
89
				<xsl:variable name="value">
90
					<xsl:choose>
91
						<xsl:when test="@value">
92
							<xsl:value-of select="@value" />
93
						</xsl:when>
94
						<xsl:otherwise>
95
							.
96
						</xsl:otherwise>
97
					</xsl:choose>
98
				</xsl:variable>
99
				<nxsl:for-each select="{@xpath}">
100
					<xsl:element name="{@name}">
101
						<xsl:if test="@external='true'">
102
							<xsl:attribute name="external">true</xsl:attribute>
103
						</xsl:if>
104
						<xsl:choose>
105
							<xsl:when test="@tokenizable='false'">
106
								<nxsl:value-of select="normalize-space({normalize-space($value)})" />
107
							</xsl:when>
108
							<xsl:otherwise>
109
								<nxsl:value-of select="{normalize-space($value)}" />
110
							</xsl:otherwise>
111
						</xsl:choose>
112
					</xsl:element>
113
				</nxsl:for-each>
114
			</xsl:otherwise>
115
		</xsl:choose>
116
	</xsl:template>
117

    
118

    
119
	<xsl:template match="FIELD" mode="result">
120
		<xsl:if test="@result='true'">
121
			<nxsl:copy-of select="{@xpath}" />
122
		</xsl:if>
123
	</xsl:template>
124

    
125
	<xsl:template match="FIELD" mode="header">
126
		<xsl:if test="@header='true'">
127
			<nxsl:copy-of select="{@xpath}" />
128
		</xsl:if>
129
	</xsl:template>
130

    
131
</xsl:stylesheet>
(1-1/3)