Changeset 2037


Ignore:
Timestamp:
07/17/12 14:57:08 (12 years ago)
Author:
dietuyt
Message:

Addition of InfoLinks? (= Description with @Link or @ArchiveHandle?), now adds a ResourceProxy? for these links.
Some code duplication has been removed by calling CreateResourceProxyTypeResource?

File:
1 edited

Legend:

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

    r2027 r2037  
    2525        <Header>
    2626            <MdCreator>imdi2clarin.xsl</MdCreator>
    27             <MdCreationDate><xsl:value-of select="format-date(current-date(), '[Y]-[M01]-[D01]')"/></MdCreationDate>
     27            <MdCreationDate>
     28                <xsl:value-of select="format-date(current-date(), '[Y]-[M01]-[D01]')"/>
     29            </MdCreationDate>
    2830            <MdSelfLink>
    2931                <xsl:choose>
    30                     <xsl:when test="not($uri-base='') and normalize-space(@ArchiveHandle)=''"><xsl:value-of select="$uri-base"/></xsl:when>
    31                     <xsl:otherwise>
    32                         test-<xsl:value-of select="@ArchiveHandle"/>
    33                     </xsl:otherwise>
     32                    <xsl:when test="not($uri-base='') and normalize-space(@ArchiveHandle)=''">
     33                        <xsl:value-of select="$uri-base"/>
     34                    </xsl:when>
     35                    <xsl:otherwise>test-<xsl:value-of select="@ArchiveHandle"/></xsl:otherwise>
    3436                </xsl:choose>
    3537            </MdSelfLink>
     
    3840            </MdProfile>
    3941            <xsl:if test="$collection">
    40                 <MdCollectionDisplayName><xsl:value-of select="$collection"/></MdCollectionDisplayName>
     42                <MdCollectionDisplayName>
     43                    <xsl:value-of select="$collection"/>
     44                </MdCollectionDisplayName>
    4145            </xsl:if>
    4246        </Header>
     
    4448            <ResourceProxyList>
    4549                <xsl:apply-templates select="//Resources" mode="linking"/>
     50                <xsl:apply-templates select="//Description[not(normalize-space(./@ArchiveHandle)='') or not(normalize-space(./@Link)='')]" mode="linking"/>
    4651                <xsl:apply-templates select="//Corpus" mode="linking"/>
    4752            </ResourceProxyList>
     
    6166                    xsi:schemaLocation="http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1271859438204/xsd">
    6267                    <xsl:call-template name="metatranscriptDelegate">
    63                         <xsl:with-param name="profile">clarin.eu:cr1:p_1271859438204</xsl:with-param>
     68                        <xsl:with-param name="profile"
     69                            >clarin.eu:cr1:p_1271859438204</xsl:with-param>
    6470                    </xsl:call-template>
    6571                </CMD>
     
    6975                    xsi:schemaLocation="http://www.clarin.eu/cmd/ http://catalog.clarin.eu/ds/ComponentRegistry/rest/registry/profiles/clarin.eu:cr1:p_1274880881885/xsd">
    7076                    <xsl:call-template name="metatranscriptDelegate">
    71                         <xsl:with-param name="profile">clarin.eu:cr1:p_1274880881885</xsl:with-param>
     77                        <xsl:with-param name="profile"
     78                            >clarin.eu:cr1:p_1274880881885</xsl:with-param>
    7279                    </xsl:call-template>
    7380                </CMD>
     
    7582            <xsl:otherwise>
    7683                <!--                Currently we are only processing 'SESSION' and 'CORPUS' types. The error displayed can be used to filter out erroneous files after processing-->
    77                 ERROR: Invalid METATRANSCRIPT Type!
    78             </xsl:otherwise>
     84                ERROR: Invalid METATRANSCRIPT Type! </xsl:otherwise>
    7985        </xsl:choose>
    8086    </xsl:template>
     
    8894                <xsl:if test="exists(child::Description)">
    8995                    <descriptions>
     96                       
     97                        <xsl:variable name="reflist">
     98                            <xsl:for-each select="Description">
     99                               
     100                                <xsl:if test="not(normalize-space(@ArchiveHandle)='') or not(normalize-space(@Link)='')">
     101                                    <xsl:value-of select="generate-id()"/>
     102                                    <xsl:text> </xsl:text>
     103                                </xsl:if>
     104                               
     105                               
     106                            </xsl:for-each>
     107                        </xsl:variable>
     108                       
     109                        <xsl:attribute name="ref" select="normalize-space($reflist)"></xsl:attribute>
     110                       
     111                       
     112                       
    90113                        <xsl:for-each select="Description">
    91                             <Description>
    92                                 <xsl:attribute name="LanguageId" select="@LanguageId"/>
    93                                 <xsl:value-of select="."/>
    94                             </Description>
     114                        <Description>
     115                            <xsl:attribute name="LanguageId" select="@LanguageId"/>
     116                            <xsl:value-of select="."/>
     117                        </Description>
    95118                        </xsl:for-each>
     119                       
    96120                    </descriptions>
    97121                </xsl:if>
     
    117141                <ResourceRef>
    118142                    <xsl:choose>
    119                         <xsl:when test="not(normalize-space(./@ArchiveHandle)='')">test-<xsl:value-of select="./@ArchiveHandle"/></xsl:when>
    120                         <xsl:when test="starts-with(., 'hdl:')"><xsl:value-of select="."/></xsl:when>
     143                        <xsl:when test="not(normalize-space(./@ArchiveHandle)='')"
     144                                >test-<xsl:value-of select="./@ArchiveHandle"/></xsl:when>
     145                        <xsl:when test="starts-with(., 'hdl:')">
     146                            <xsl:value-of select="."/>
     147                        </xsl:when>
    121148                        <xsl:when test="$uri-base=''"><xsl:value-of select="."/>.cmdi</xsl:when>
    122                         <xsl:otherwise><xsl:value-of select="concat(resolve-uri(normalize-space(.), $uri-base), '.cmdi')"/></xsl:otherwise>
     149                        <xsl:otherwise>
     150                            <xsl:value-of
     151                                select="concat(resolve-uri(normalize-space(.), $uri-base), '.cmdi')"
     152                            />
     153                        </xsl:otherwise>
    123154                    </xsl:choose>
    124155                </ResourceRef>
     
    127158    </xsl:template>
    128159
     160    <!-- Create ResourceProxy for MediaFile and WrittenResource -->
    129161    <xsl:template match="Resources" mode="linking">
    130162        <xsl:for-each select="MediaFile">
    131             <ResourceProxy id="{generate-id()}">
    132                 <ResourceType>
    133                     <xsl:if test="exists(Format) and not(empty(Format))">
    134                         <xsl:attribute name="mimetype">
    135                             <xsl:value-of select="./Format"/>
    136                         </xsl:attribute>
    137                     </xsl:if>Resource</ResourceType>
    138                 <ResourceRef>
    139                     <xsl:choose>
    140                         <xsl:when test="not(normalize-space(ResourceLink/@ArchiveHandle)='')"><xsl:value-of select="ResourceLink/@ArchiveHandle"/></xsl:when>
    141                         <xsl:when test="not($uri-base='')"><xsl:value-of select="resolve-uri(normalize-space(ResourceLink/.), $uri-base)"/></xsl:when>
    142                     </xsl:choose>
    143                 </ResourceRef>
    144             </ResourceProxy>
     163            <xsl:call-template name="CreateResourceProxyTypeResource"/>       
    145164        </xsl:for-each>
    146165        <xsl:for-each select="WrittenResource">
    147             <ResourceProxy id="{generate-id()}">
    148                 <ResourceType>
    149                     <xsl:if test="exists(Format) and not(empty(Format))">
    150                         <xsl:attribute name="mimetype">
    151                             <xsl:value-of select="./Format"/>
    152                         </xsl:attribute>
    153                     </xsl:if>Resource</ResourceType>
    154                 <ResourceRef>
    155                     <xsl:choose>
    156                         <xsl:when test="not(normalize-space(ResourceLink/@ArchiveHandle)='')"><xsl:value-of select="ResourceLink/@ArchiveHandle"/></xsl:when>
    157                         <xsl:when test="not($uri-base='')"><xsl:value-of select="resolve-uri(normalize-space(ResourceLink/.), $uri-base)"/></xsl:when>
    158                     </xsl:choose>
    159                 </ResourceRef>
    160             </ResourceProxy>
     166            <xsl:call-template name="CreateResourceProxyTypeResource"/>
    161167        </xsl:for-each>
    162168    </xsl:template>
     169   
     170    <!-- Create ResourceProxy for Info files -->
     171    <xsl:template match="//Description[@ArchiveHandle or @Link]" mode="linking">
     172        <xsl:call-template name="CreateResourceProxyTypeResource"/>
     173    </xsl:template>
     174   
     175    <!-- to be called during the creation of the ResourceProxyList (in linking mode) -->
     176    <xsl:template name="CreateResourceProxyTypeResource">
     177        <ResourceProxy id="{generate-id()}">
     178            <ResourceType>
     179                <xsl:if test="exists(Format) and not(empty(Format))">
     180                    <xsl:attribute name="mimetype">
     181                        <xsl:value-of select="./Format"/>
     182                    </xsl:attribute>
     183                </xsl:if>Resource</ResourceType>
     184            <ResourceRef>
     185                <xsl:choose>
     186                    <xsl:when test="not(normalize-space(ResourceLink/@ArchiveHandle)='')">
     187                        <xsl:value-of select="ResourceLink/@ArchiveHandle"/>
     188                    </xsl:when>
     189                    <xsl:when test="not($uri-base='')">
     190                        <xsl:value-of
     191                            select="resolve-uri(normalize-space(ResourceLink/.), $uri-base)"/>
     192                    </xsl:when>
     193                    <!-- for info files the @ArchiveHandle or @Link is part of the Description element - preference for ArchiveHandle -->
     194                    <xsl:when test="not(normalize-space(@ArchiveHandle)='')">
     195                        <xsl:value-of select="@ArchiveHandle"/>
     196                    </xsl:when>
     197                    <xsl:when test="not(normalize-space(@Link)='')">
     198                        <xsl:value-of select="@Link"/>
     199                    </xsl:when>
     200                </xsl:choose>
     201            </ResourceRef>
     202        </ResourceProxy>
     203    </xsl:template>
     204
     205
    163206
    164207    <xsl:template match="Session">
     
    170213                <descriptions>
    171214                    <xsl:for-each select="Description">
     215                        <xsl:if test="@ArchiveHandle">
     216                            <xsl:attribute name="ref" select="generate-id()"/>
     217                        </xsl:if>
    172218                        <Description>
    173219                            <xsl:attribute name="LanguageId" select="@LanguageId"/>
Note: See TracChangeset for help on using the changeset viewer.