Project

General

Profile

1
<?xml version="1.0" encoding="UTF-8"?>
2
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3
                xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr="http://www.driver-repository.eu/namespace/dr"
4
                xmlns:dri="http://www.driver-repository.eu/namespace/dri" xmlns:oaa="http://namespace.openaire.eu/oaa"
5
                xmlns:oaf="http://namespace.openaire.eu/oaf" xmlns:dnet="eu.dnetlib.data.transform.xml.OafToHbaseXsltFunctions"
6
                xmlns:date="java.lang.System"
7
                xmlns:exslt="http://exslt.org/common"
8
                version="1.0"
9
                extension-element-prefixes="exslt"
10
                exclude-result-prefixes="xsl dc dr dri oaa oaf dnet exslt date">
11

    
12
    <xsl:output omit-xml-declaration="yes" indent="yes"/>
13

    
14
    <xsl:param name="trust" select="string('0.9')"/>
15
    <xsl:param name="provenance" select="string('UNKNOWN')"/>
16

    
17
    <xsl:template match="/*">
18
        <xsl:variable name="about" select="/*[local-name() = 'record']/*[local-name() = 'about']"/>
19
        <xsl:variable name="dateofcollection" select="//dr:dateOfCollection"/>
20
        <xsl:variable name="dateoftransformation" select="//dr:dateOfTransformation"/>
21

    
22
        <xsl:variable name="metadata" select="exslt:node-set(//*[local-name()='metadata']/*)"/>
23

    
24
        <xsl:choose>
25
            <xsl:when test="count($metadata) = 0">
26
                <ROWS/>
27
            </xsl:when>
28
            <xsl:otherwise>
29

    
30
                <xsl:variable name="objidentifier" select="/record/*[local-name() = 'header']/*[local-name() = 'objIdentifier']"/>
31

    
32
                <xsl:variable name="resultId" select="dnet:oafSimpleId('result', $objidentifier)"/>
33

    
34
                <xsl:variable name="hostedbyid" select="dnet:oafSplitId('datasource', //oaf:hostedBy/@id)"/>
35
                <xsl:variable name="hostedbyname" select="//oaf:hostedBy/@name"/>
36

    
37
                <xsl:variable name="collectedfromid" select="dnet:oafSplitId('datasource', //oaf:collectedFrom/@id)"/>
38
                <xsl:variable name="collectedfromname" select="//oaf:collectedFrom/@name"/>
39

    
40
                <xsl:variable name="originalidTest" select="/record/*[local-name() = 'header']/*[local-name() = 'recordIdentifier']"/>
41
                <xsl:variable name="originalid">
42
                    <xsl:choose>
43
                        <xsl:when test="contains($originalidTest, '::')">
44
                            <xsl:value-of select="substring-after($originalidTest, '::')"/>
45
                        </xsl:when>
46
                        <xsl:otherwise>
47
                            <xsl:value-of select="$originalidTest"/>
48
                        </xsl:otherwise>
49
                    </xsl:choose>
50
                </xsl:variable>
51

    
52
                <xsl:variable name="result"
53
                              select="dnet:oafResult($resultId, $provenance, $trust, $about, $hostedbyid, $hostedbyname,
54
	                          $collectedfromid, $collectedfromname, $originalid, $dateofcollection, $dateoftransformation, $metadata)"/>
55

    
56
                <ROWS>
57
	                <ROW targetKey="{$resultId}" targetColumnFamily="result">
58
                        <QUALIFIER name="{concat('update_', date:nanoTime())}" type="base64"><xsl:value-of select="$result"/></QUALIFIER>
59
                    </ROW>
60
                </ROWS>
61
            </xsl:otherwise>
62
        </xsl:choose>
63
    </xsl:template>
64

    
65
</xsl:stylesheet>
(3-3/4)