Revision 52256
Added by Claudio Atzori almost 6 years ago
modules/dnet-openaireplus-workflows/trunk/src/main/resources/eu/dnetlib/msro/openaireplus/workflows/index/openaireLayoutToRecordStylesheet.xsl | ||
---|---|---|
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 |
|
|
5 |
<xsl:output omit-xml-declaration="yes" method="xml"/> |
|
6 |
<xsl:namespace-alias stylesheet-prefix="nxsl" result-prefix="xsl"/> |
|
7 |
|
|
8 |
<xsl:param name="format"/> |
|
9 |
|
|
10 |
<xsl:template match="/"> |
|
11 |
<xsl:apply-templates select="//LAYOUT"/> |
|
12 |
</xsl:template> |
|
13 |
|
|
14 |
<xsl:template match="LAYOUT"> |
|
15 |
<nxsl:stylesheet version="1.0" |
|
16 |
xmlns:dnet="eu.dnetlib.miscutils.functional.xml.DnetXsltFunctions" |
|
17 |
xmlns:dri="http://www.driver-repository.eu/namespace/dri" |
|
18 |
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="contains(@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:choose> |
|
87 |
<xsl:when test="@tokenizable='false'"> |
|
88 |
<nxsl:value-of select="normalize-space({normalize-space($value)})"/> |
|
89 |
</xsl:when> |
|
90 |
<xsl:otherwise> |
|
91 |
<nxsl:value-of select="{normalize-space($value)}"/> |
|
92 |
</xsl:otherwise> |
|
93 |
</xsl:choose> |
|
94 |
</xsl:element> |
|
95 |
</nxsl:for-each> |
|
96 |
</xsl:otherwise> |
|
97 |
</xsl:choose> |
|
98 |
</xsl:template> |
|
99 |
|
|
100 |
|
|
101 |
<xsl:template match="FIELD" mode="result"> |
|
102 |
<xsl:if test="@result='true'"> |
|
103 |
<nxsl:copy-of select="{@xpath}"/> |
|
104 |
</xsl:if> |
|
105 |
</xsl:template> |
|
106 |
|
|
107 |
<xsl:template match="FIELD" mode="header"> |
|
108 |
<xsl:if test="@header='true'"> |
|
109 |
<nxsl:copy-of select="{@xpath}"/> |
|
110 |
</xsl:if> |
|
111 |
</xsl:template> |
|
112 |
|
|
113 |
</xsl:stylesheet> |
Also available in: Unified diff
openaireLayoutToRecordStylesheet.xsl moved in dnet-openaireplus-mapping-utils so that it can be shared among openaire workflows and the rest controller for direct index feeding