1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
3
|
xmlns:nxsl="http://www.w3.org/1999/XSL/TransformXX" version="1.0"
|
4
|
>
|
5
|
|
6
|
<xsl:output omit-xml-declaration="yes" method="xml"/>
|
7
|
<xsl:namespace-alias stylesheet-prefix="nxsl" result-prefix="xsl"/>
|
8
|
|
9
|
<xsl:param name="format"/>
|
10
|
|
11
|
<xsl:template match="/">
|
12
|
<xsl:apply-templates select="//LAYOUT"/>
|
13
|
</xsl:template>
|
14
|
|
15
|
<xsl:template match="LAYOUT">
|
16
|
<nxsl:stylesheet xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions"
|
17
|
version="1.0"
|
18
|
extension-element-prefixes="exsl" exclude-result-prefixes="dnet">
|
19
|
|
20
|
<nxsl:output version="1.0" omit-xml-declaration="yes"
|
21
|
method="xml"/>
|
22
|
|
23
|
<nxsl:variable name="format">
|
24
|
<xsl:value-of select="$format"/>
|
25
|
</nxsl:variable>
|
26
|
|
27
|
<nxsl:template match="/">
|
28
|
<indexRecord>
|
29
|
<indexRecordIdentifier>
|
30
|
<nxsl:value-of select="//dri:objIdentifier"/>
|
31
|
</indexRecordIdentifier>
|
32
|
<targetFields>
|
33
|
<nxsl:if test="count(//*[local-name()='metadata']/*) > 0">
|
34
|
<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']"/>
|
35
|
</nxsl:if>
|
36
|
</targetFields>
|
37
|
<dnetResult>
|
38
|
<nxsl:copy-of select="/*[local-name()='record']/*[local-name()='result']/*[local-name()='header']"/>
|
39
|
<metadata>
|
40
|
<xsl:apply-templates select="FIELDS/FIELD"
|
41
|
mode="result"/>
|
42
|
</metadata>
|
43
|
</dnetResult>
|
44
|
</indexRecord>
|
45
|
</nxsl:template>
|
46
|
</nxsl:stylesheet>
|
47
|
</xsl:template>
|
48
|
|
49
|
<xsl:template match="FIELD[@indexable='true']">
|
50
|
<xsl:choose>
|
51
|
<xsl:when test="@constant">
|
52
|
<xsl:element name="{@name}">
|
53
|
<xsl:value-of select="@constant"/>
|
54
|
</xsl:element>
|
55
|
</xsl:when>
|
56
|
<xsl:when test="@value and not(@xpath)">
|
57
|
<xsl:choose>
|
58
|
<xsl:when test="@type='date'">
|
59
|
<nxsl:variable name="{@name}" select="dnet:normalizeDate(normalize-space({normalize-space(@value)}), false())"/>
|
60
|
<nxsl:if test="string-length(${@name}) > 0">
|
61
|
<nxsl:element name="{@name}">
|
62
|
<nxsl:value-of select="${@name}"/>
|
63
|
</nxsl:element>
|
64
|
</nxsl:if>
|
65
|
</xsl:when>
|
66
|
<xsl:otherwise>
|
67
|
<nxsl:element name="{@name}">
|
68
|
<nxsl:value-of select="{@value}"/>
|
69
|
</nxsl:element>
|
70
|
</xsl:otherwise>
|
71
|
</xsl:choose>
|
72
|
</xsl:when>
|
73
|
<xsl:otherwise>
|
74
|
<xsl:variable name="value">
|
75
|
<xsl:choose>
|
76
|
<xsl:when test="@value">
|
77
|
<xsl:value-of select="@value"/>
|
78
|
</xsl:when>
|
79
|
<xsl:otherwise>
|
80
|
.
|
81
|
</xsl:otherwise>
|
82
|
</xsl:choose>
|
83
|
</xsl:variable>
|
84
|
<nxsl:for-each select="{@xpath}">
|
85
|
<xsl:element name="{@name}">
|
86
|
<xsl:if test="@external='true'">
|
87
|
<xsl:attribute name="external">true</xsl:attribute>
|
88
|
</xsl:if>
|
89
|
<xsl:choose>
|
90
|
<xsl:when test="@tokenizable='false'">
|
91
|
<nxsl:value-of select="normalize-space({normalize-space($value)})"/>
|
92
|
</xsl:when>
|
93
|
<xsl:otherwise>
|
94
|
<nxsl:value-of select="{normalize-space($value)}"/>
|
95
|
</xsl:otherwise>
|
96
|
</xsl:choose>
|
97
|
</xsl:element>
|
98
|
</nxsl:for-each>
|
99
|
</xsl:otherwise>
|
100
|
</xsl:choose>
|
101
|
</xsl:template>
|
102
|
|
103
|
|
104
|
<xsl:template match="FIELD" mode="result">
|
105
|
<xsl:if test="@result='true'">
|
106
|
<nxsl:copy-of select="{@xpath}"/>
|
107
|
</xsl:if>
|
108
|
</xsl:template>
|
109
|
|
110
|
<xsl:template match="FIELD" mode="header">
|
111
|
<xsl:if test="@header='true'">
|
112
|
<nxsl:copy-of select="{@xpath}"/>
|
113
|
</xsl:if>
|
114
|
</xsl:template>
|
115
|
|
116
|
</xsl:stylesheet>
|