Changeset 2554 for metadata/branches


Ignore:
Timestamp:
02/08/13 13:14:40 (12 years ago)
Author:
twagoo
Message:

Removed some code duplication in imdi2clarin stylesheet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • metadata/branches/clarin2imdi-resourcerefs/toolkit/xslt/imdi2clarin.xsl

    r2552 r2554  
    2424    URI. Omit this if you are unsure. -->
    2525    <xsl:param name="uri-base"/>
    26 
     26   
    2727    <!-- definition of the SRU-searchable collections at TLA (for use later on) -->
    2828    <xsl:variable name="SruSearchable">childes,ESF corpus,IFA corpus,MPI CGN,talkbank</xsl:variable>
     
    187187    <!-- to be called during the creation of the ResourceProxyList (in linking mode) -->
    188188    <xsl:template name="CreateResourceProxyTypeResource">
    189        
    190         <xsl:variable name="resourceId">
    191             <xsl:choose>
    192                 <xsl:when test="$keep-resource-refs and string-length(@ResourceId) &gt; 0">
    193                     <xsl:value-of select="@ResourceId" />
    194                 </xsl:when>
    195                 <xsl:otherwise>
    196                     <xsl:value-of select="generate-id()"/>
    197                 </xsl:otherwise>
    198             </xsl:choose>
    199         </xsl:variable>
    200        
    201189        <ResourceProxy>
    202190            <xsl:attribute name="id">
    203                 <xsl:value-of select="$resourceId"/>
     191                <xsl:apply-templates mode="CreateRefFromResourceId" select="."/>
    204192            </xsl:attribute>
    205193            <ResourceType>
     
    229217        </ResourceProxy>
    230218    </xsl:template>
    231 
    232     <!-- Used to create the ResourceRef (single ref) attribute on actors and languages -->
     219   
     220    <!--
     221        Used to create id on ResourceProxy elements and ref on MediaFile and WrittenResource elements
     222        from ResourceId attribute on original MediaFile and WritteResource elements
     223    -->
     224    <xsl:template match="MediaFile|WrittenResource" mode="CreateRefFromResourceId">
     225        <xsl:choose>
     226            <xsl:when test="$keep-resource-refs and string-length(@ResourceId) &gt; 0">
     227                <xsl:value-of select="@ResourceId" />
     228            </xsl:when>
     229            <xsl:otherwise>
     230                <xsl:value-of select="generate-id()"/>
     231            </xsl:otherwise>
     232        </xsl:choose>
     233    </xsl:template>
     234   
     235    <!-- Used to create the ref attribute on actors and languages from the original ResourceRef (single ref) -->
    233236    <xsl:template match="@ResourceRef" mode="CreateResourceRefAttribute">
    234237        <xsl:choose>
     
    244247    </xsl:template>
    245248   
    246     <!-- Used to create the ResourceRefs attribute (multiple refs) on sources -->
     249    <!-- Used to create the ref attribute on sources from the original ResourceRefs attribute (multiple refs) -->
    247250    <xsl:template match="@ResourceRefs" mode="CreateResourceRefAttribute">
    248251        <xsl:variable name="resourceRefsValid">
     
    669672
    670673    <xsl:template match="MediaFile">
    671        
    672         <xsl:variable name="resourceRef">
    673             <xsl:choose>
    674                 <xsl:when test="$keep-resource-refs and string-length(@ResourceId) &gt; 0">
    675                     <xsl:value-of select="@ResourceId" />
    676                 </xsl:when>
    677                 <xsl:otherwise>
    678                     <xsl:value-of select="generate-id()"/>
    679                 </xsl:otherwise>
    680             </xsl:choose>
    681         </xsl:variable>
    682        
    683674        <MediaFile>
    684             <xsl:attribute name="ref">
    685                 <xsl:value-of select="$resourceRef"/>
     675            <xsl:attribute name="ref">           
     676                <xsl:apply-templates mode="CreateRefFromResourceId" select="."/>
    686677            </xsl:attribute>
    687678            <ResourceLink>
     
    757748
    758749    <xsl:template match="WrittenResource">
    759        
    760         <xsl:variable name="resourceRef">
    761             <xsl:choose>
    762                 <xsl:when test="$keep-resource-refs and string-length(@ResourceId) &gt; 0">
    763                     <xsl:value-of select="@ResourceId" />
    764                 </xsl:when>
    765                 <xsl:otherwise>
    766                     <xsl:value-of select="generate-id()"/>
    767                 </xsl:otherwise>
    768             </xsl:choose>
    769         </xsl:variable>
    770        
    771         <WrittenResource>
    772             <xsl:attribute name="ref">
    773                 <xsl:value-of select="$resourceRef"/>
     750        <WrittenResource>           
     751            <xsl:attribute name="ref">           
     752                <xsl:apply-templates mode="CreateRefFromResourceId" select="."/>
    774753            </xsl:attribute>
    775754            <ResourceLink>
Note: See TracChangeset for help on using the changeset viewer.