xslt for transforming CoL Response to internal synonym response format
authorCherian Mathew <c.mathew@bgbm.org>
Tue, 3 Apr 2012 15:34:11 +0000 (15:34 +0000)
committerCherian Mathew <c.mathew@bgbm.org>
Tue, 3 Apr 2012 15:34:11 +0000 (15:34 +0000)
.gitattributes
DataCleaning/xml/colres_to_synres.xsl [new file with mode: 0755]

index 8225d62ed81a387505584a53523a6576eb7437d5..0531963dff46652a8b6b00f60121f8b899902991 100644 (file)
@@ -3,6 +3,7 @@ DataCleaning/README.txt -text
 DataCleaning/workflows/data_cleaning/data_cleaning.t2flow -text
 DataCleaning/workflows/data_cleaning/test_input.txt -text
 DataCleaning/workflows/nested/grefine/grefine.t2flow -text
+DataCleaning/xml/colres_to_synres.xsl -text svneol=unset#application/xml
 DataCleaning/xml/csvHeader_beta.txt -text
 DataCleaning/xml/gbifResponse_to_csv.xsl -text svneol=unset#application/xml
 DataCleaning/xml/slwArtDataBank_to_csv.xsl -text svneol=unset#application/xml
diff --git a/DataCleaning/xml/colres_to_synres.xsl b/DataCleaning/xml/colres_to_synres.xsl
new file mode 100755 (executable)
index 0000000..2f962c9
--- /dev/null
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+     <!--
+          Document   : synreq_to_col.xsl
+          Author     : c.mathew
+          Description: converts the Catalogue of Life response to the internal
+                       synonym response.
+          
+          -->
+
+     <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+       <xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
+       
+       <xsl:param name="syncheckid"></xsl:param>
+
+       <xsl:template match="/">   
+       <synonymResponse checklist="Catalogue Of Life">
+         <xsl:apply-templates select="results/result"/>
+       </synonymResponse>            
+     </xsl:template>
+
+     <xsl:template match="result">
+       <xsl:choose>
+         <xsl:when test="name_status='accepted name'">
+           <acceptedName>
+             <taxonName>
+               <authorship><xsl:apply-templates select="author"/></authorship>
+               <name>
+                 <nameComplete><xsl:apply-templates select="name"/></nameComplete>
+                 <atomisedName>
+                   <subGenus>
+                     <genusPart><xsl:apply-templates select="genus"/></genusPart>
+                     <specificEpithet><xsl:apply-templates select="species"/></specificEpithet>
+                     <infraspecificEpithet><xsl:apply-templates select="infraspecies"/></infraspecificEpithet>
+                   </subGenus>
+                 </atomisedName>
+                 <nameStatus><xsl:apply-templates select="name_status"/></nameStatus>
+               </name>
+               <rank><xsl:apply-templates select="rank"/></rank>
+             </taxonName>
+             <source>
+               <name><xsl:apply-templates select="source_database"/></name>
+               <url><xsl:apply-templates select="source_database_url"/></url>
+             </source>
+             <info>
+               <url><xsl:apply-templates select="url"/></url>
+             </info>
+           </acceptedName>
+         </xsl:when>
+         <xsl:otherwise>
+           <otherName>
+             <taxonName>
+               <authorship><xsl:apply-templates select="author"/></authorship>
+               <name>
+                 <nameComplete><xsl:apply-templates select="name"/></nameComplete>
+                 <atomisedName>
+                   <subGenus>
+                     <genusPart><xsl:apply-templates select="genus"/></genusPart>
+                     <specificEpithet><xsl:apply-templates select="species"/></specificEpithet>
+                     <infraspecificEpithet><xsl:apply-templates select="infraspecies"/></infraspecificEpithet>
+                   </subGenus>
+                 </atomisedName>
+                 <nameStatus><xsl:apply-templates select="name_status"/></nameStatus>
+               </name>
+               <rank><xsl:apply-templates select="rank"/></rank>
+             </taxonName>
+             <source>
+               <name><xsl:apply-templates select="source_database"/></name>
+               <url><xsl:apply-templates select="source_database_url"/></url>
+             </source>
+             <info>
+               <url><xsl:apply-templates select="url"/></url>
+             </info>
+           </otherName>
+         </xsl:otherwise>
+       </xsl:choose>
+       <xsl:apply-templates select="synonyms/synonym"/>       
+     </xsl:template>
+
+     <xsl:template match="synonym">
+       <synonym>
+         <taxonName>
+           <authorship><xsl:apply-templates select="author"/></authorship>
+           <name>
+             <nameComplete><xsl:apply-templates select="name"/></nameComplete>
+             <atomisedName>
+               <subGenus>
+                 <genusPart><xsl:apply-templates select="genus"/></genusPart>
+                 <specificEpithet><xsl:apply-templates select="species"/></specificEpithet>
+                 <infraspecificEpithet><xsl:apply-templates select="infraspecies"/></infraspecificEpithet>
+               </subGenus>
+             </atomisedName>
+             <nameStatus><xsl:apply-templates select="name_status"/></nameStatus>
+           </name>
+           <rank><xsl:apply-templates select="rank"/></rank>
+         </taxonName>
+         <source>
+           <name><xsl:apply-templates select="source_database"/></name>
+           <url><xsl:apply-templates select="source_database_url"/></url>
+         </source>
+         <info>
+           <url><xsl:apply-templates select="url"/></url>
+         </info>
+       </synonym>
+     </xsl:template>
+
+     
+
+
+   </xsl:stylesheet>