From 365de973741f9eaee72127b26b6f3ed0909d5143 Mon Sep 17 00:00:00 2001
From: bourgesl <bourges.laurent@gmail.com>
Date: Wed, 18 Jul 2018 14:38:32 +0200
Subject: [PATCH] added Funder support

---
 resources/xsl/3.1/xml2doi.xsl                 |  22 +++-
 resources/xsl/4.1/xml2doi.xsl                 |  63 +++++++++-
 ...atacite-example-fundingReference-v.4.1.csv |  16 +--
 ...atacite-example-fundingReference-v.4.1.xml | 118 +++++++++---------
 4 files changed, 145 insertions(+), 74 deletions(-)

diff --git a/resources/xsl/3.1/xml2doi.xsl b/resources/xsl/3.1/xml2doi.xsl
index 7bf71b3..18a0aec 100644
--- a/resources/xsl/3.1/xml2doi.xsl
+++ b/resources/xsl/3.1/xml2doi.xsl
@@ -102,6 +102,11 @@
         <!--
         11	AlternateIdentifier	0-n	-
         -->
+        <xsl:if test="property[@key='alternateIdentifier']">
+            <alternateIdentifiers>
+                <xsl:apply-templates select="property[@key='alternateIdentifier']" mode="alternateIdentifier"/>
+            </alternateIdentifiers>
+        </xsl:if>
 
         <!--
         12	RelatedIdentifier	0-n	"relatedIdentifier:Cites:DOI..."
@@ -270,15 +275,26 @@
     </xsl:template>
 
     <xsl:template match="property" mode="resourceType">
-        <xsl:if test="text()">
+        <xsl:if test="@attr1">
             <resourceType>
+                <xsl:attribute name="resourceTypeGeneral">
+                    <xsl:value-of select="@attr1"/>
+                </xsl:attribute>
+                <xsl:value-of select="text()"/>
+            </resourceType>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template match="property" mode="alternateIdentifier">
+        <xsl:if test="text()">
+            <alternateIdentifier>
                 <xsl:if test="@attr1">
-                    <xsl:attribute name="resourceTypeGeneral">
+                    <xsl:attribute name="alternateIdentifierType">
                         <xsl:value-of select="@attr1"/>
                     </xsl:attribute>
                 </xsl:if>
                 <xsl:value-of select="text()"/>
-            </resourceType>
+            </alternateIdentifier>
         </xsl:if>
     </xsl:template>
 
diff --git a/resources/xsl/4.1/xml2doi.xsl b/resources/xsl/4.1/xml2doi.xsl
index 7249efd..672f3ac 100644
--- a/resources/xsl/4.1/xml2doi.xsl
+++ b/resources/xsl/4.1/xml2doi.xsl
@@ -21,7 +21,7 @@
 
     <!-- DOI metadata template -->
     <xsl:template match="/">
-        <resource xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4/metadata.xsd">
+        <resource xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
             <xsl:apply-templates select="./rows"/>
         </resource>
     </xsl:template>
@@ -103,6 +103,11 @@
         <!--
         11	AlternateIdentifier	0-n	-
         -->
+        <xsl:if test="property[@key='alternateIdentifier']">
+            <alternateIdentifiers>
+                <xsl:apply-templates select="property[@key='alternateIdentifier']" mode="alternateIdentifier"/>
+            </alternateIdentifiers>
+        </xsl:if>
 
         <!--
         12	RelatedIdentifier	0-n	"relatedIdentifier:Cites:DOI..."
@@ -162,6 +167,15 @@
                 <xsl:apply-templates select="property[@key='geoLocationPoint' or @key='geoLocationBox' or @key='geoLocationPlace']" mode="geoLocation"/>
             </geoLocations>
         </xsl:if>
+
+        <!--
+        19	Funder	0-n	"funderName..."
+        -->
+        <xsl:if test="property[@key='funderName']">
+            <fundingReferences>
+                <xsl:apply-templates select="property[@key='funderName']" mode="funder"/>
+            </fundingReferences>
+        </xsl:if>
     </xsl:template>
 
 
@@ -271,15 +285,26 @@
     </xsl:template>
 
     <xsl:template match="property" mode="resourceType">
-        <xsl:if test="text()">
+        <xsl:if test="@attr1">
             <resourceType>
+                <xsl:attribute name="resourceTypeGeneral">
+                    <xsl:value-of select="@attr1"/>
+                </xsl:attribute>
+                <xsl:value-of select="text()"/>
+            </resourceType>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template match="property" mode="alternateIdentifier">
+        <xsl:if test="text()">
+            <alternateIdentifier>
                 <xsl:if test="@attr1">
-                    <xsl:attribute name="resourceTypeGeneral">
+                    <xsl:attribute name="alternateIdentifierType">
                         <xsl:value-of select="@attr1"/>
                     </xsl:attribute>
                 </xsl:if>
                 <xsl:value-of select="text()"/>
-            </resourceType>
+            </alternateIdentifier>
         </xsl:if>
     </xsl:template>
 
@@ -358,6 +383,20 @@
         </xsl:if>
     </xsl:template>
 
+    <xsl:template match="property" mode="funder">
+        <xsl:if test="text()">
+            <fundingReference>
+                <funderName>
+                    <xsl:value-of select="text()"/>
+                </funderName>
+                <!-- optional awardNumber attribute -->
+                <xsl:apply-templates select="attribute[@key='awardNumber']" mode="awardNumber"/>
+                <!-- optional awardTitle attribute -->
+                <xsl:apply-templates select="attribute[@key='awardTitle']" mode="awardTitle"/>
+            </fundingReference>
+        </xsl:if>
+    </xsl:template>
+
     <!-- attributes -->
 
     <xsl:template match="attribute" mode="rightsURI">
@@ -387,4 +426,20 @@
         </xsl:if>
     </xsl:template>
 
+    <xsl:template match="attribute" mode="awardNumber">
+        <xsl:if test="text()">
+            <awardNumber>
+                <xsl:value-of select="text()"/>
+            </awardNumber>
+        </xsl:if>
+    </xsl:template>
+
+    <xsl:template match="attribute" mode="awardTitle">
+        <xsl:if test="text()">
+            <awardTitle>
+                <xsl:value-of select="text()"/>
+            </awardTitle>
+        </xsl:if>
+    </xsl:template>
+
 </xsl:stylesheet>
diff --git a/src/test/resources/xml/datacite-example-fundingReference-v.4.1.csv b/src/test/resources/xml/datacite-example-fundingReference-v.4.1.csv
index 80da725..895d42f 100644
--- a/src/test/resources/xml/datacite-example-fundingReference-v.4.1.csv
+++ b/src/test/resources/xml/datacite-example-fundingReference-v.4.1.csv
@@ -16,12 +16,12 @@ resourceType:Dataset;;
 alternateIdentifier:URL;http://zenodo.org/record/47394;
 relatedIdentifier:HasPart:URL;https://zenodo.org/record/47394/files/Data_All_Internal_motivations.pdf;
 relatedIdentifier:HasPart:URL;https://zenodo.org/record/47394/files/survey_questionnaire_internal_motivations.pdf;
-rights;Open Access;;rightsURI;info:eu-repo/semantics/openAccess;
-rights;Creative Commons Zero 1.0 Universal;;rightsURI;http://creativecommons.org/publicdomain/zero/1.0/;
+rights;Open Access;rightsURI;info:eu-repo/semantics/openAccess;
+rights;Creative Commons Zero 1.0 Universal;rightsURI;http://creativecommons.org/publicdomain/zero/1.0/;
 description:Abstract;"<p>These files provide the original survey data of the paper on motivations for biodiversity conservation in Europe. This paper analyses the possibility of building a mutually supportive dynamics between
-      internally and<br /> externally motivated behaviour for biodiversity conservation and ecosystem services provision. To this<br /> purpose a face to face survey amongst 169 key actors of 34 highly successful and prominent
-      biodiversity<br /> arrangements in seven EU countries was conducted. The main<br /> finding of the paper is the feasibility of<br /> combining inherently intrinsically motivated behaviours (providing enjoyment, pleasure from<br
-      /> experimentation and learning, aesthetic satisfaction) and internalized extrinsic motivations (related<br /> to the identification with the collective goals of conservation policy) through a common set of governance<br /> features.
-      Successful initiatives that combine internal and external motivations share the following<br /> features: inclusive decision making processes, a broad monitoring by &ldquo,peers&rdquo, beyond the core staff of the<br />
-      initiatives, and a context that is supportive for the building of autonomous actor competences. These<br /> findings are in line with the psycho-sociological theory of motivation, which shows the importance of a<br /> psycho-social
-      context leading to a subjective perception of autonomy and a sense of competence of the<br /> actors.</p>";
+            internally and<br /> externally motivated behaviour for biodiversity conservation and ecosystem services provision. To this<br /> purpose a face to face survey amongst 169 key actors of 34 highly successful and prominent
+            biodiversity<br /> arrangements in seven EU countries was conducted. The main<br /> finding of the paper is the feasibility of<br /> combining inherently intrinsically motivated behaviours (providing enjoyment, pleasure from<br
+            /> experimentation and learning, aesthetic satisfaction) and internalized extrinsic motivations (related<br /> to the identification with the collective goals of conservation policy) through a common set of governance<br /> features.
+            Successful initiatives that combine internal and external motivations share the following<br /> features: inclusive decision making processes, a broad monitoring by &ldquo,peers&rdquo, beyond the core staff of the<br />
+            initiatives, and a context that is supportive for the building of autonomous actor competences. These<br /> findings are in line with the psycho-sociological theory of motivation, which shows the importance of a<br /> psycho-social
+            context leading to a subjective perception of autonomy and a sense of competence of the<br /> actors.</p>";
diff --git a/src/test/resources/xml/datacite-example-fundingReference-v.4.1.xml b/src/test/resources/xml/datacite-example-fundingReference-v.4.1.xml
index ddec7dc..b6d14a6 100644
--- a/src/test/resources/xml/datacite-example-fundingReference-v.4.1.xml
+++ b/src/test/resources/xml/datacite-example-fundingReference-v.4.1.xml
@@ -1,61 +1,61 @@
 <resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://datacite.org/schema/kernel-4" xsi:schemaLocation="http://datacite.org/schema/kernel-4 http://schema.datacite.org/meta/kernel-4.1/metadata.xsd">
-  <identifier identifierType="DOI">10.5281/zenodo.47394</identifier>
-  <creators>
-    <creator>
-      <creatorName nameType="Personal">Dedeurwaerdere, Tom</creatorName>
-      <givenName>Tom</givenName>
-      <familyName>Dedeurwaerdere</familyName>
-      <affiliation>Université catholique de Louvain</affiliation>
-    </creator>
-  </creators>
-  <titles>
-    <title xml:lang="en">Combining internal and external motivations in multi-actor governance arrangements for biodiversity and ecosystem services</title>
-  </titles>
-  <publisher>Zenodo</publisher>
-  <publicationYear>2016</publicationYear>
-  <subjects>
-    <subject xml:lang="en">Internal motivations</subject>
-    <subject xml:lang="en">Biodiversity</subject>
-    <subject xml:lang="en">Multi-actor governance</subject>
-    <subject xml:lang="en">Payment for ecosystem services</subject>
-    <subject xml:lang="en">Crowding out</subject>
-  </subjects>
-  <fundingReferences>
-    <fundingReference>
-      <funderName>European Commission</funderName>
-      <funderIdentifier funderIdentifierType="Crossref Funder ID">http://doi.org/10.13039/501100000780</funderIdentifier>
-      <awardNumber awardURI="http://cordis.europa.eu/project/rcn/100180_en.html">282625</awardNumber>
-      <awardTitle>MOTivational strength of ecosystem services and alternative ways to express the value of BIOdiversity</awardTitle>
-    </fundingReference>
-    <fundingReference>
-      <funderName>European Commission</funderName>
-      <funderIdentifier funderIdentifierType="Crossref Funder ID">http://doi.org/10.13039/501100000780</funderIdentifier>
-      <awardNumber awardURI="http://cordis.europa.eu/project/rcn/100603_en.html">284382</awardNumber>
-      <awardTitle>Institutionalizing global genetic-resource commons. Global Strategies for accessing and using essential public knowledge assets in the life sciences</awardTitle>
-    </fundingReference>
-  </fundingReferences>
-  <dates>
-    <date dateType="Issued">2016-03-11</date>
-  </dates>
-  <resourceType resourceTypeGeneral="Dataset"/>
-  <alternateIdentifiers>
-    <alternateIdentifier alternateIdentifierType="URL">http://zenodo.org/record/47394</alternateIdentifier>
-  </alternateIdentifiers>
-  <relatedIdentifiers>
-    <relatedIdentifier relatedIdentifierType="URL" relationType="HasPart">https://zenodo.org/record/47394/files/Data_All_Internal_motivations.pdf</relatedIdentifier>
-    <relatedIdentifier relatedIdentifierType="URL" relationType="HasPart">https://zenodo.org/record/47394/files/survey_questionnaire_internal_motivations.pdf</relatedIdentifier>
-  </relatedIdentifiers>
-  <rightsList>
-    <rights rightsURI="info:eu-repo/semantics/openAccess">Open Access</rights>
-    <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Zero 1.0 Universal</rights>
-  </rightsList>
-  <descriptions>
-    <description xml:lang="en" descriptionType="Abstract">&lt;p&gt;These files provide the original survey data of the paper on motivations for biodiversity conservation in Europe. This paper analyses the possibility of building a mutually supportive dynamics between
-      internally and&lt;br /&gt; externally motivated behaviour for biodiversity conservation and ecosystem services provision. To this&lt;br /&gt; purpose a face to face survey amongst 169 key actors of 34 highly successful and prominent
-      biodiversity&lt;br /&gt; arrangements in seven EU countries was conducted. The main&lt;br /&gt; finding of the paper is the feasibility of&lt;br /&gt; combining inherently intrinsically motivated behaviours (providing enjoyment, pleasure from&lt;br
-      /&gt; experimentation and learning, aesthetic satisfaction) and internalized extrinsic motivations (related&lt;br /&gt; to the identification with the collective goals of conservation policy) through a common set of governance&lt;br /&gt; features.
-      Successful initiatives that combine internal and external motivations share the following&lt;br /&gt; features: inclusive decision making processes, a broad monitoring by &amp;ldquo;peers&amp;rdquo; beyond the core staff of the&lt;br /&gt;
-      initiatives, and a context that is supportive for the building of autonomous actor competences. These&lt;br /&gt; findings are in line with the psycho-sociological theory of motivation, which shows the importance of a&lt;br /&gt; psycho-social
-      context leading to a subjective perception of autonomy and a sense of competence of the&lt;br /&gt; actors.&lt;/p&gt;</description>
-  </descriptions>
+    <identifier identifierType="DOI">10.5281/zenodo.47394</identifier>
+    <creators>
+        <creator>
+            <creatorName nameType="Personal">Dedeurwaerdere, Tom</creatorName>
+            <givenName>Tom</givenName>
+            <familyName>Dedeurwaerdere</familyName>
+            <affiliation>Université catholique de Louvain</affiliation>
+        </creator>
+    </creators>
+    <titles>
+        <title xml:lang="en">Combining internal and external motivations in multi-actor governance arrangements for biodiversity and ecosystem services</title>
+    </titles>
+    <publisher>Zenodo</publisher>
+    <publicationYear>2016</publicationYear>
+    <subjects>
+        <subject xml:lang="en">Internal motivations</subject>
+        <subject xml:lang="en">Biodiversity</subject>
+        <subject xml:lang="en">Multi-actor governance</subject>
+        <subject xml:lang="en">Payment for ecosystem services</subject>
+        <subject xml:lang="en">Crowding out</subject>
+    </subjects>
+    <fundingReferences>
+        <fundingReference>
+            <funderName>European Commission</funderName>
+            <funderIdentifier funderIdentifierType="Crossref Funder ID">http://doi.org/10.13039/501100000780</funderIdentifier>
+            <awardNumber awardURI="http://cordis.europa.eu/project/rcn/100180_en.html">282625</awardNumber>
+            <awardTitle>MOTivational strength of ecosystem services and alternative ways to express the value of BIOdiversity</awardTitle>
+        </fundingReference>
+        <fundingReference>
+            <funderName>European Commission</funderName>
+            <funderIdentifier funderIdentifierType="Crossref Funder ID">http://doi.org/10.13039/501100000780</funderIdentifier>
+            <awardNumber awardURI="http://cordis.europa.eu/project/rcn/100603_en.html">284382</awardNumber>
+            <awardTitle>Institutionalizing global genetic-resource commons. Global Strategies for accessing and using essential public knowledge assets in the life sciences</awardTitle>
+        </fundingReference>
+    </fundingReferences>
+    <dates>
+        <date dateType="Issued">2016-03-11</date>
+    </dates>
+    <resourceType resourceTypeGeneral="Dataset"/>
+    <alternateIdentifiers>
+        <alternateIdentifier alternateIdentifierType="URL">http://zenodo.org/record/47394</alternateIdentifier>
+    </alternateIdentifiers>
+    <relatedIdentifiers>
+        <relatedIdentifier relatedIdentifierType="URL" relationType="HasPart">https://zenodo.org/record/47394/files/Data_All_Internal_motivations.pdf</relatedIdentifier>
+        <relatedIdentifier relatedIdentifierType="URL" relationType="HasPart">https://zenodo.org/record/47394/files/survey_questionnaire_internal_motivations.pdf</relatedIdentifier>
+    </relatedIdentifiers>
+    <rightsList>
+        <rights rightsURI="info:eu-repo/semantics/openAccess">Open Access</rights>
+        <rights rightsURI="http://creativecommons.org/publicdomain/zero/1.0/">Creative Commons Zero 1.0 Universal</rights>
+    </rightsList>
+    <descriptions>
+        <description xml:lang="en" descriptionType="Abstract">&lt;p&gt;These files provide the original survey data of the paper on motivations for biodiversity conservation in Europe. This paper analyses the possibility of building a mutually supportive dynamics between
+            internally and&lt;br /&gt; externally motivated behaviour for biodiversity conservation and ecosystem services provision. To this&lt;br /&gt; purpose a face to face survey amongst 169 key actors of 34 highly successful and prominent
+            biodiversity&lt;br /&gt; arrangements in seven EU countries was conducted. The main&lt;br /&gt; finding of the paper is the feasibility of&lt;br /&gt; combining inherently intrinsically motivated behaviours (providing enjoyment, pleasure from&lt;br
+            /&gt; experimentation and learning, aesthetic satisfaction) and internalized extrinsic motivations (related&lt;br /&gt; to the identification with the collective goals of conservation policy) through a common set of governance&lt;br /&gt; features.
+            Successful initiatives that combine internal and external motivations share the following&lt;br /&gt; features: inclusive decision making processes, a broad monitoring by &amp;ldquo;peers&amp;rdquo; beyond the core staff of the&lt;br /&gt;
+            initiatives, and a context that is supportive for the building of autonomous actor competences. These&lt;br /&gt; findings are in line with the psycho-sociological theory of motivation, which shows the importance of a&lt;br /&gt; psycho-social
+            context leading to a subjective perception of autonomy and a sense of competence of the&lt;br /&gt; actors.&lt;/p&gt;</description>
+    </descriptions>
 </resource>
-- 
GitLab