Project

General

Profile

« Previous | Next » 

Revision 48139

integrated (hopefully) all required changes from dnet40

View differences:

openaireLayoutToRecordStylesheet.xsl
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 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">
3
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:nxsl="http://www.w3.org/1999/XSL/TransformXX">
5 4

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

  
9
	<xsl:param name="format" />
8
	<xsl:param name="format"/>
10 9

  
11 10
	<xsl:template match="/">
12
		<xsl:apply-templates select="//LAYOUT" />
11
		<xsl:apply-templates select="//LAYOUT"/>
13 12
	</xsl:template>
14 13

  
15 14
	<xsl:template match="LAYOUT">
16 15
		<nxsl:stylesheet version="1.0"
17
			xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions"
18
			xmlns:exsl="http://exslt.org/common" xmlns:oaf="http://namespace.openaire.eu/oaf"
19
      		extension-element-prefixes="exsl" exclude-result-prefixes="dnet">
16
		                 xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions"
17
		                 xmlns:dri="http://www.driver-repository.eu/namespace/dri"
18
		                 exclude-result-prefixes="dnet">
20 19

  
21 20
			<nxsl:output version="1.0" omit-xml-declaration="yes"
22
				method="xml" />
21
			             method="xml"/>
23 22

  
24 23
			<nxsl:variable name="format">
25
				<xsl:value-of select="$format" />
24
				<xsl:value-of select="$format"/>
26 25
			</nxsl:variable>
27 26

  
28 27
			<nxsl:template match="/">
29 28
				<indexRecord>
30 29
					<indexRecordIdentifier>
31
						<nxsl:value-of select="//dri:objIdentifier" />
30
						<nxsl:value-of select="//dri:objIdentifier"/>
32 31
					</indexRecordIdentifier>
33 32
					<targetFields>
34 33
						<nxsl:if test="count(//*[local-name()='metadata']/*) &gt; 0">
35
							<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']" />
36
						</nxsl:if>		
34
							<xsl:apply-templates select="FIELDS/FIELD[@indexable='true']"/>
35
						</nxsl:if>
37 36
					</targetFields>
38 37
					<dnetResult>
39
						<nxsl:copy-of select="/*[local-name()='record']/*[local-name()='result']/*[local-name()='header']" />
38
						<nxsl:copy-of select="/*[local-name()='record']/*[local-name()='result']/*[local-name()='header']"/>
40 39
						<metadata>
41 40
							<xsl:apply-templates select="FIELDS/FIELD"
42
								mode="result" />
41
							                     mode="result"/>
43 42
						</metadata>
44 43
					</dnetResult>
45 44
				</indexRecord>
......
51 50
		<xsl:choose>
52 51
			<xsl:when test="@constant">
53 52
				<xsl:element name="{@name}">
54
					<xsl:value-of select="@constant" />
53
					<xsl:value-of select="@constant"/>
55 54
				</xsl:element>
56 55
			</xsl:when>
57 56
			<xsl:when test="@value and not(@xpath)">
58
                <xsl:choose>
59
                    <xsl:when test="@type='date'">
60
                    	<nxsl:variable name="{@name}" select="dnet:normalizeDate(normalize-space({normalize-space(@value)}), false())"/>
61
                    	<nxsl:if test="string-length(${@name}) &gt; 0">
62
                            <nxsl:element name="{@name}">
63
                            	<nxsl:value-of select="${@name}" />
64
                            </nxsl:element>
65
                        </nxsl:if>
66
                    </xsl:when>
67
                    <xsl:otherwise>
68
                        <nxsl:element name="{@name}">
69
                            <nxsl:value-of select="{@value}" />
70
                        </nxsl:element>
71
                    </xsl:otherwise>
72
                </xsl:choose>
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}) &gt; 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>
73 72
			</xsl:when>
74 73
			<xsl:otherwise>
75 74
				<xsl:variable name="value">
76 75
					<xsl:choose>
77 76
						<xsl:when test="@value">
78
							<xsl:value-of select="@value" />
77
							<xsl:value-of select="@value"/>
79 78
						</xsl:when>
80 79
						<xsl:otherwise>
81 80
							.
......
86 85
					<xsl:element name="{@name}">
87 86
						<xsl:choose>
88 87
							<xsl:when test="@tokenizable='false'">
89
								<nxsl:value-of select="normalize-space({normalize-space($value)})" />
88
								<nxsl:value-of select="normalize-space({normalize-space($value)})"/>
90 89
							</xsl:when>
91 90
							<xsl:otherwise>
92
								<nxsl:value-of select="{normalize-space($value)}" />
91
								<nxsl:value-of select="{normalize-space($value)}"/>
93 92
							</xsl:otherwise>
94 93
						</xsl:choose>
95 94
					</xsl:element>
......
101 100

  
102 101
	<xsl:template match="FIELD" mode="result">
103 102
		<xsl:if test="@result='true'">
104
			<nxsl:copy-of select="{@xpath}" />
103
			<nxsl:copy-of select="{@xpath}"/>
105 104
		</xsl:if>
106 105
	</xsl:template>
107 106

  
108 107
	<xsl:template match="FIELD" mode="header">
109 108
		<xsl:if test="@header='true'">
110
			<nxsl:copy-of select="{@xpath}" />
109
			<nxsl:copy-of select="{@xpath}"/>
111 110
		</xsl:if>
112 111
	</xsl:template>
113 112

  

Also available in: Unified diff