Changeset 818 for metadata


Ignore:
Timestamp:
10/26/10 15:47:56 (14 years ago)
Author:
dietuyt
Message:

Several updates to process the olac:code attributes correctly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • metadata/trunk/toolkit/xslt/olac2cmdi.xsl

    r771 r818  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <xsl:stylesheet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"  xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:defns="http://www.openarchives.org/OAI/2.0/">
     2<xsl:stylesheet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     3    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
     4    xmlns:dc="http://purl.org/dc/elements/1.1/"
     5    xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
     6    xmlns:defns="http://www.openarchives.org/OAI/2.0/"
     7    xmlns:olac="http://www.language-archives.org/OLAC/1.0/"
     8    xsi:schemaLocation="    http://purl.org/dc/elements/1.1/    http://www.language-archives.org/OLAC/1.0/dc.xsd    http://purl.org/dc/terms/    http://www.language-archives.org/OLAC/1.0/dcterms.xsd    http://www.language-archives.org/OLAC/1.0/    http://www.language-archives.org/OLAC/1.0/olac.xsd    http://www.language-archives.org/OLAC/1.0/third-party/software.xsd ">
    39
    410    <!-- run on ubtunu with: saxonb-xslt -ext:on -it main ~/svn/clarin/metadata/trunk/toolkit/xslt/olac2cmdi.xsl  -->
     
    713
    814    <!-- identity copy -->
    9     <xsl:template match="@*|node()">
     15<!--    <xsl:template match="@*|node()">
    1016        <xsl:copy>
    1117            <xsl:apply-templates select="@*|node()"/>
    1218        </xsl:copy>
    1319    </xsl:template>
    14 
     20-->
     21   
    1522    <xsl:template match="/">
    16         <CMD xsi:schemaLocation="http://www.clarin.eu/cmd http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1271859438236/xsd">
    17             <Header>               
    18             <MdCreator>olac2cmdi.xsl</MdCreator>
    19             <MdCreationDate>
    20                 <xsl:variable name="date"><xsl:value-of select="//defns:datestamp"></xsl:value-of></xsl:variable>
    21                 <xsl:choose>
    22                     <xsl:when test="contains($date,'T')">
    23                         <xsl:value-of select="substring-before($date,'T')"/>
    24                     </xsl:when>
    25                     <xsl:otherwise>
    26                         <xsl:value-of select="$date"/>
    27                     </xsl:otherwise>
    28                 </xsl:choose>
    29             </MdCreationDate>
    30             <MdSelfLink><xsl:value-of select="//defns:identifier" /></MdSelfLink>
    31             <MdProfile>clarin.eu:cr1:p_1271859438236</MdProfile>
    32         </Header>
    33         <Resources>
    34             <ResourceProxyList></ResourceProxyList>
    35             <JournalFileProxyList></JournalFileProxyList>
    36             <ResourceRelationList></ResourceRelationList>
    37         </Resources>
    38         <Components>
    39             <olac>
    40                
    41                 <xsl:for-each select="//dc:contributor">
    42                     <olac-contributor><xsl:apply-templates select="."/></olac-contributor>   
    43                 </xsl:for-each>
    44                
    45                 <xsl:for-each select="//dc:creator">
    46                     <olac-creator><xsl:apply-templates select="."/></olac-creator>   
    47                 </xsl:for-each>
    48              
    49                 <xsl:for-each select="//dc:date">
    50                     <olac-date><xsl:apply-templates select="."/></olac-date>   
    51                 </xsl:for-each> 
    52                
    53                 <xsl:for-each select="//dc:description">
    54                     <olac-description><xsl:apply-templates select="."/></olac-description>   
    55                 </xsl:for-each>
    56                
    57                 <xsl:for-each select="//dc:format">
    58                     <olac-format><xsl:apply-templates select="."/></olac-format>   
    59                 </xsl:for-each>
    60                
    61                
    62                 <xsl:for-each select="//dc:identifier">
    63                     <olac-identifier><xsl:apply-templates select="."/></olac-identifier>   
    64                 </xsl:for-each>
    65                
    66                 <xsl:for-each select="//dc:language">
    67                     <olac-language><xsl:apply-templates select="."/></olac-language>   
    68                 </xsl:for-each>
    69                
    70                 <xsl:for-each select="//dc:publisher">
    71                     <olac-publisher><xsl:apply-templates select="."/></olac-publisher>   
    72                 </xsl:for-each>
    73                
    74                 <xsl:for-each select="//dc:relation">
    75                     <olac-relation><xsl:apply-templates select="."/></olac-relation>   
    76                 </xsl:for-each>
    77                
    78                 <xsl:for-each select="//dc:rights">
    79                     <olac-rights><xsl:apply-templates select="."/></olac-rights>   
    80                 </xsl:for-each>
    81                
    82                 <xsl:for-each select="//dc:source">
    83                     <olac-source><xsl:apply-templates select="."/></olac-source>   
    84                 </xsl:for-each>
    85                
    86                 <xsl:for-each select="//dc:subject">
    87                     <olac-subject><xsl:apply-templates select="."/></olac-subject>   
    88                 </xsl:for-each>
    89                                
    90                 <xsl:for-each select="//dc:title">
    91                     <title><xsl:apply-templates select="."/></title>   
    92                 </xsl:for-each>
    93                
    94                 <xsl:for-each select="//dc:type">
    95                     <type><xsl:apply-templates select="."/></type>   
    96                 </xsl:for-each>
    97    
    98             </olac>
    99         </Components>
     23        <CMD
     24            xsi:schemaLocation="http://www.clarin.eu/cmd http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1271859438236/xsd">
     25            <Header>
     26                <MdCreator>olac2cmdi.xsl</MdCreator>
     27                <MdCreationDate>
     28                    <xsl:variable name="date">
     29                        <xsl:value-of select="//defns:datestamp"/>
     30                    </xsl:variable>
     31                    <xsl:choose>
     32                        <xsl:when test="contains($date,'T')">
     33                            <xsl:value-of select="substring-before($date,'T')"/>
     34                        </xsl:when>
     35                        <xsl:otherwise>
     36                            <xsl:value-of select="$date"/>
     37                        </xsl:otherwise>
     38                    </xsl:choose>
     39                </MdCreationDate>
     40                <MdSelfLink>
     41                    <xsl:value-of select="//defns:identifier"/>
     42                </MdSelfLink>
     43                <MdProfile>clarin.eu:cr1:p_1271859438236</MdProfile>
     44            </Header>
     45            <Resources>
     46                <ResourceProxyList/>
     47                <JournalFileProxyList/>
     48                <ResourceRelationList/>
     49            </Resources>
     50            <Components>
     51                <olac>
     52
     53                    <xsl:apply-templates select="//dc:contributor"/>
     54                    <xsl:apply-templates select="//dc:coverage"/>
     55                    <xsl:apply-templates select="//dc:creator"/>
     56                    <xsl:apply-templates select="//dc:date"/>
     57                    <xsl:apply-templates select="//dc:description"/>
     58                    <xsl:apply-templates select="//dc:format"/>
     59                    <xsl:apply-templates select="//dc:identifier"/>
     60                    <xsl:apply-templates select="//dc:language"/>
     61                    <xsl:apply-templates select="//dc:publisher"/>
     62                    <xsl:apply-templates select="//dc:relation"/>
     63                    <xsl:apply-templates select="//dc:rights"/>
     64                    <xsl:apply-templates select="//dc:source"/>
     65                    <xsl:apply-templates select="//dc:subject"/>
     66                    <xsl:apply-templates select="//dc:title"/>
     67                    <xsl:apply-templates select="//dc:type"/>
     68
     69                </olac>
     70            </Components>
    10071        </CMD>
    10172    </xsl:template>
    102    
    103    
    104     <xsl:template match="dc:*">
    105         <xsl:value-of select="."/>
    106     </xsl:template>
    107    
     73
     74    <xsl:template match="dc:contributor">
     75        <olac-contributor>
     76            <xsl:if test="@xsi:type='olac:role'">
     77                <xsl:attribute name="olac-role">
     78                    <xsl:value-of select="@olac:code"/>
     79                </xsl:attribute>
     80            </xsl:if>
     81            <xsl:value-of select="."/>
     82        </olac-contributor>
     83    </xsl:template>
     84
     85
     86    <xsl:template match="dc:creator">
     87        <olac-creator>
     88            <xsl:value-of select="."/>
     89        </olac-creator>
     90    </xsl:template>
     91
     92    <xsl:template match="dc:date">
     93        <olac-date>
     94            <xsl:value-of select="."/>
     95        </olac-date>
     96    </xsl:template>
     97
     98    <xsl:template match="dc:description">
     99        <olac-description>
     100           <xsl:apply-templates select="./@xml:lang"/>           
     101            <xsl:value-of select="."/>
     102        </olac-description>
     103    </xsl:template>
     104
     105    <xsl:template match="dc:format">
     106        <olac-format>
     107            <xsl:value-of select="."/>
     108        </olac-format>
     109    </xsl:template>
     110
     111    <xsl:template match="dc:identifier">
     112        <olac-identifier>
     113            <xsl:value-of select="."/>
     114        </olac-identifier>
     115    </xsl:template>
     116
     117    <xsl:template match="dc:language">
     118        <olac-language>
     119            <xsl:value-of select="."/>
     120        </olac-language>
     121    </xsl:template>
     122
     123    <xsl:template match="dc:language[@xsi:type='olac:language']" priority="3">
     124        <olac-language>
     125            <xsl:attribute name="olac-language">
     126                <xsl:value-of select="@olac:code"/>
     127            </xsl:attribute>
     128        </olac-language>
     129    </xsl:template>
     130
     131
     132    <xsl:template match="dc:publisher">
     133        <olac-publisher>
     134            <xsl:value-of select="."/>
     135        </olac-publisher>
     136    </xsl:template>
     137
     138    <xsl:template match="dc:relation">
     139        <olac-relation>
     140            <xsl:value-of select="."/>
     141        </olac-relation>
     142    </xsl:template>
     143
     144
     145    <xsl:template match="dc:rights">
     146        <olac-rights>
     147            <xsl:value-of select="."/>
     148        </olac-rights>
     149    </xsl:template>
     150
     151
     152    <xsl:template match="//dc:subject[@xsi:type='olac:linguistic-field']" priority="3">
     153        <olac-subject>
     154            <xsl:attribute name="olac-linguistic-field">
     155                <xsl:value-of select="@olac:code"/>
     156            </xsl:attribute>
     157        </olac-subject>
     158    </xsl:template>
     159
     160    <xsl:template match="//dc:subject[@xsi:type='olac:discourse-type']" priority="3">
     161        <olac-subject>
     162            <xsl:attribute name="olac-discourse-type">
     163                <xsl:value-of select="@olac:code"/>
     164            </xsl:attribute>
     165        </olac-subject>
     166    </xsl:template>
     167
     168
     169    <xsl:template match="//dc:subject" priority="1">
     170        <olac-subject>
     171            <xsl:apply-templates select="./@xml:lang"/>
     172            <xsl:value-of select="."/>
     173        </olac-subject>
     174    </xsl:template>
     175
     176
     177    <xsl:template match="//dc:title">
     178        <title>
     179            <xsl:apply-templates select="./@xml:lang"/>
     180            <xsl:value-of select="."/>
     181        </title>
     182    </xsl:template>
     183
     184
     185    <xsl:template match="//dc:type[@xsi:type='olac:discourse-type']" priority="2">
     186        <type>
     187            <xsl:attribute name="olac-discourse-type">
     188                <xsl:value-of select="@olac:code"/>
     189            </xsl:attribute>
     190        </type>
     191    </xsl:template>
     192
     193
     194    <xsl:template match="//dc:type[@xsi:type='olac:linguistic-type']" priority="2">
     195        <type>
     196            <xsl:attribute name="olac-linguistic-type">
     197                <xsl:value-of select="@olac:code"/>
     198            </xsl:attribute>
     199        </type>
     200    </xsl:template>
     201
     202
     203    <xsl:template match="//dc:type" priority="1">
     204        <type>
     205            <xsl:value-of select="."/>
     206        </type>
     207    </xsl:template>
     208
     209    <xsl:template match="@xml:lang">
     210        <xsl:attribute name="xml:lang">
     211            <xsl:value-of select="."/>
     212        </xsl:attribute>
     213    </xsl:template>
     214
    108215
    109216    <xsl:template name="main">
    110         <xsl:for-each select="collection('file:////home/dietuyt/olac?select=*.xml;recurse=yes;on-error=ignore')">
     217        <xsl:for-each
     218            select="collection('file:////home/dietuyt/olac?select=*.xml;recurse=yes;on-error=ignore')">
    111219            <xsl:result-document href="{document-uri(.)}.cmdi">
    112220                <xsl:apply-templates select="."/>
    113221            </xsl:result-document>
    114222        </xsl:for-each>
    115     </xsl:template> 
    116    
     223    </xsl:template>
     224
    117225
    118226</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.