Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet version="2.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" encoding="UTF-8" />
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 version="2.0"
17
		    xmlns="http://www.openarchives.org/OAI/2.0/"
18
			xmlns:dri="http://www.driver-repository.eu/namespace/dri"
19
			xmlns:dc="http://purl.org/dc/elements/1.1/"
20
			xmlns:crm="http://www.cidoc-crm.org/cidoc-crm/"
21
			xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
22
			xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
23
			xmlns:foaf="http://xmlns.com/foaf/0.1/"
24
			xmlns:crmpe="http://parthenos.d4science.org/CRMext/CRMpe.rdfs/"
25
			exclude-result-prefixes="dc crm rdf rdfs foaf crmpe">
26

    
27
			<nxsl:output version="1.0" omit-xml-declaration="yes" method="xml" encoding="UTF8" />
28

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

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

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

    
112

    
113
	<xsl:template match="FIELD" mode="result">
114
		<xsl:if test="@result='true'">
115
			<nxsl:copy-of select="{@xpath}"/>
116
		</xsl:if>
117
	</xsl:template>
118

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

    
125
</xsl:stylesheet>
    (1-1/1)