Project

General

Profile

« Previous | Next » 

Revision 52131

Updated new claim transformation with UNIBI's contribution on date management (see #2973#note-11)

View differences:

claims_crossref_2_OAF.xml
4 4
        <RESOURCE_TYPE value="TransformationRuleDSResourceType"/>
5 5
        <RESOURCE_KIND value="TransformationRuleDSResources"/>
6 6
        <RESOURCE_URI value=""/>
7
        <DATE_OF_CREATION value="2017-06-30T13:01:32+02:00"/>
7
        <DATE_OF_CREATION value="2017-07-18T18:16:55+02:00"/>
8 8
    </HEADER>
9 9
    <BODY>
10 10
        <CONFIGURATION>
11 11
            <IMPORTED/>
12 12
            <SCRIPT>
13 13
                <TITLE>claims_crossref_2_OAF</TITLE>
14
                <CODE><![CDATA[
15
declare_script "claims_crossref_2_OAF";
16
declare_ns oaf = "http://namespace.openaire.eu/oaf";
17
declare_ns dri = "http://www.driver-repository.eu/namespace/dri";
18
declare_ns dr = "http://www.driver-repository.eu/namespace/dr";
19
declare_ns dc = "http://purl.org/dc/elements/1.1/";
20
declare_ns prov = "http://www.openarchives.org/OAI/2.0/provenance";
21
$var0 = "''";
22
$var1 = "'corda_______::'";
23
$varDummy = "''";
14
                <CODE>
15
                    declare_script "claims_crossref_2_OAF";
16
                    declare_ns oaf = "http://namespace.openaire.eu/oaf";
17
                    declare_ns dri = "http://www.driver-repository.eu/namespace/dri";
18
                    declare_ns dr = "http://www.driver-repository.eu/namespace/dr";
19
                    declare_ns dc = "http://purl.org/dc/elements/1.1/";
20
                    declare_ns prov = "http://www.openarchives.org/OAI/2.0/provenance";
21
                    $var0 = "''";
22
                    $var1 = "'corda_______::'";
23
                    $varDummy = "''";
24 24

  
25
static $varDatasourceid = "'openaire____::crossref'";
26
static $varOfficialname = "'Crossref'";
25
                    static $varDatasourceid = "'openaire____::crossref'";
26
                    static $varOfficialname = "'Crossref'";
27 27

  
28
static $varUnknownRepoid = "'openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18'";
29
static $varUnknownReponame = "'Unknown Repository'";
28
                    static $varUnknownRepoid = "'openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18'";
29
                    static $varUnknownReponame = "'Unknown Repository'";
30 30

  
31
if xpath:"not(matches(//objIdentifier, '^[\w_]{12}::\w{32}$'))" dri:objIdentifier = skipRecord(); else $varDummy = "''";
32
dri:objIdentifier = xpath:"//objIdentifier";
33
dri:recordIdentifier = xpath:"//dri:recordIdentifier";
34
dri:dateOfCollection = xpath:"//dri:dateOfCollection";
35
static dr:dateOfTransformation = xpath:"current-dateTime()";
31
                    if xpath:"not(matches(//objIdentifier, '^[\w_]{12}::\w{32}$'))" dri:objIdentifier = skipRecord(); else $varDummy = "''";
36 32

  
37
apply xpath:"//message/items/author" if xpath:"true()" dc:creator =  xpath:"concat(./family, ', ', ./given)"; else $varDummy = "''";
38
apply xpath:"//message/items/title" if xpath:"string-length(.) > 0" dc:title = xpath:"normalize-space(.)"; else $varDummy = "''";
39
apply xpath:"//message/items/publisher" if xpath:"string-length(.) > 0" dc:publisher = xpath:"normalize-space(.)"; else $varDummy = "''";
40
apply xpath:"//message/items/source" if xpath:"string-length(.) > 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
41
apply xpath:"//message/items/container-title" if xpath:"string-length(.) > 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
42
apply xpath:"//message/items/subject" if xpath:"string-length(.) > 0" dc:subject = xpath:"normalize-space(.)"; else $varDummy = "''";
33
                    dri:objIdentifier = xpath:"//objIdentifier";
34
                    dri:recordIdentifier = xpath:"//dri:recordIdentifier";
35
                    dri:dateOfCollection = xpath:"//dri:dateOfCollection";
36
                    static dr:dateOfTransformation = xpath:"current-dateTime()";
43 37

  
44
$varHttpTest = "''";
45
apply xpath:"//message/items/URL" if xpath:"starts-with(normalize-space(.), 'http')" dc:identifier = xpath:"normalize-space(.)"; else dr:CobjIdentifier = xpath:"normalize-space(.)";
38
                    apply xpath:"//message/items/author" if xpath:"true()" dc:creator =  xpath:"concat(./family, ', ', ./given)"; else $varDummy = "''";
39
                    apply xpath:"//message/items/title" if xpath:"string-length(.) &gt; 0" dc:title = xpath:"normalize-space(.)"; else $varDummy = "''";
40
                    apply xpath:"//message/items/publisher" if xpath:"string-length(.) &gt; 0" dc:publisher = xpath:"normalize-space(.)"; else $varDummy = "''";
41
                    apply xpath:"//message/items/source" if xpath:"string-length(.) &gt; 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
42
                    apply xpath:"//message/items/container-title" if xpath:"string-length(.) &gt; 0" dc:source = xpath:"normalize-space(.)"; else $varDummy = "''";
43
                    apply xpath:"//message/items/subject" if xpath:"string-length(.) &gt; 0" dc:subject = xpath:"normalize-space(.)"; else $varDummy = "''";
46 44

  
47
//message/items/type
48
//dc:language = Convert(xpath:"//dc:language", Languages);
49
//TODO: ask UNIBI how to do for dates
50
//<issued>
51
         // <date-parts>
52
           // <array>2014</array>
53
           // <array>1</array>
54
           // <array>28</array>
55
          //</date-parts>
56
       // </issued>
57
//oaf:dateAccepted = Convert(xpath:"//message/items/issued/date-parts/array", DateISO8601, "yyyy-MM-dd", "min()");
58
apply xpath:"//message/items/type" if xpath:"." dr:CobjCategory = Convert(xpath:"normalize-space(.)", TextTypologies); else dr:CobjCategory = "0001";
59
oaf:accessrights = "'UNKNOWN'";
45
                    $varHttpTest = "''";
46
                    apply xpath:"//message/items/URL" if xpath:"starts-with(normalize-space(.), 'http')" dc:identifier = xpath:"normalize-space(.)"; else dr:CobjIdentifier = xpath:"normalize-space(.)";
60 47

  
61
oaf:collectedFrom = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
62
oaf:hostedBy = set("''", @name = $varUnknownReponame; , @id = $varUnknownRepoid;);
48
                    // first check whether //issued/date-parts contains at most 3 (array) fields, with apt lengths; then alternate the values with '-', giving month/day standard length or dummy values before.
49
                    apply xpath:"//*[local-name()='issued']/*[local-name()='date-parts'][max((count(*),3))=3 and string-length(*[1])=4 and max((subsequence(*/string-length(),2,2),2))=2]" if xpath:"." oaf:dateAccepted = xpath:"string-join((*[1], substring(substring(concat('0',*[2],'1'),string-length(*[2])),1,2), substring(substring(concat('0',*[3],'1'),string-length(*[3])),1,2)), '-')"; else $varDummy = "''";
63 50

  
64
$varId = identifierExtract('["//message/items/DOI", "//message/items/URL"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/<>]*/[^\s"<>]+)');
65
oaf:identifier = set(xpath:"$varId//value", @identifierType = "doi";);
51
                    apply xpath:"//message/items/type" if xpath:"." dr:CobjCategory = Convert(xpath:"normalize-space(.)", TextTypologies); else dr:CobjCategory = "0001";
52
                    oaf:accessrights = "'UNKNOWN'";
66 53

  
67
oaf:datasourceprefix = xpath:"//oaf:datasourceprefix";
68
about = xpath:"//about";
54
                    oaf:collectedFrom = set("''", @name = $varOfficialname; , @id = $varDatasourceid;);
55
                    oaf:hostedBy = set("''", @name = $varUnknownReponame; , @id = $varUnknownRepoid;);
69 56

  
57
                    $varId = identifierExtract('["//message/items/DOI", "//message/items/URL"]' , xpath:"./*[local-name()='record']" , '(10[.][0-9]{4,}[^\s"/&lt;&gt;]*/[^\s"&lt;&gt;]+)');
58
                    oaf:identifier = set(xpath:"$varId//value", @identifierType = "doi";);
70 59

  
71
end
72
]]></CODE>
60
                    oaf:datasourceprefix = xpath:"//oaf:datasourceprefix";
61
                    about = xpath:"//about";
62
                    end
63
                </CODE>
73 64
            </SCRIPT>
74 65
        </CONFIGURATION>
75 66
        <STATUS/>
76 67
        <SECURITY_PARAMETERS/>
77 68
    </BODY>
78
</RESOURCE_PROFILE>
69
</RESOURCE_PROFILE>

Also available in: Unified diff