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="count(//*[local-name()='metadata']/*) &gt; 0">
38
							<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']" />
39
						</nxsl:if>		
40
					</targetFields>
41
					<result>
42
						<header>
43
							<dri:objIdentifier>
44
								<nxsl:value-of select="//dri:objIdentifier" />
45
							</dri:objIdentifier>
46
							<dri:repositoryId>
47
								<nxsl:value-of select="//dri:repositoryId" />
48
							</dri:repositoryId>
49
							<dri:dateOfCollection>
50
								<nxsl:value-of select="//dri:dateOfCollection" />
51
							</dri:dateOfCollection>
52
							<xsl:apply-templates select="FIELDS/FIELD"
53
								mode="header" />
54
						</header>
55
						<metadata>
56
							<xsl:apply-templates select="FIELDS/FIELD"
57
								mode="result" />
58
						</metadata>
59
					</result>
60
				</indexRecord>
61
			</nxsl:template>
62
		</nxsl:stylesheet>
63
	</xsl:template>
64

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

    
116

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

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

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