Ignore:
Timestamp:
09/19/12 10:36:16 (12 years ago)
Author:
vronk
Message:

intermediate commit of older minor(?) changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/scripts/smc_commons.xsl

    r1876 r2235  
    77    <xsl:include href="cmd_includes.xsl"/>   
    88    <xsl:include href="dcr_rdf2terms.xsl"/>
     9    <xsl:include href="dcr_dcif2terms.xsl"/>
    910   
    1011    <!-- use either input (precedence) or the config-file as the termsets configuration -->
     
    2627<!-- intermediate datasets bound into variables,to prevent calling the function every time -->
    2728   <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" />
     29    <xsl:variable name="rr-relations" select="my:getData('rr-relations')" />
     30    <!-- rr-relations expanded with terms-->
     31    <xsl:variable name="rr-terms" select="my:getData('rr-terms')" />
    2832   <xsl:variable name="cmd-terms" select="my:getData('cmd-terms')" />
     33    <xsl:variable name="cmd-terms-nested" select="my:getData('cmd-terms-nested')" />
    2934   <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" />
    3035   <xsl:variable name="isocat-languages" select="my:getData('isocat-languages')" />
     
    4146        <xsl:variable name="cached_data_file" select="concat($cache_dir, $key, '.xml')"></xsl:variable>
    4247        <xsl:message>
    43             cache: <xsl:value-of select="$cache" />
     48            cache: <xsl:value-of select="$cache" /> -
    4449            <xsl:value-of select="$cached_data_file" />: <xsl:value-of select="doc-available($cached_data_file)" />
    4550        </xsl:message>
     
    4853                <xsl:message>reading in: <xsl:value-of select="$cached_data_file" />                   
    4954                </xsl:message>
    50                 <xsl:copy-of select="document($cached_data_file)"></xsl:copy-of>
     55                <xsl:copy-of select="doc($cached_data_file)"></xsl:copy-of>
    5156            </xsl:when>
    5257            <xsl:when test="$key='cmd-profiles-raw'">
     
    5762            </xsl:when>
    5863            <xsl:when test="$key='cmd-terms'">
    59                 <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription)" />
    60             </xsl:when>
     64                <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription,false())" />
     65            </xsl:when>
     66            <xsl:when test="$key='cmd-terms-nested'">
     67                <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription,true())" />
     68            </xsl:when>
     69            <xsl:when test="$key='cmd-terms-nested-minimal'">
     70                <xsl:apply-templates select="$cmd-terms-nested" mode="min-context"></xsl:apply-templates>
     71            </xsl:when>           
    6172            <xsl:when test="$key='dcr-terms'">
    6273                <xsl:call-template name="load-dcr" />                                                           
    6374            </xsl:when>
     75            <xsl:when test="$key='rr-relations'">
     76                <xsl:call-template name="load-rr-relations" />                                                         
     77            </xsl:when>
     78            <xsl:when test="$key='rr-terms'">
     79                <xsl:call-template name="rr-terms" />                                                           
     80            </xsl:when>           
    6481            <xsl:when test="$key='termsets'">
    6582                <xsl:call-template name="termsets" />                                                           
     
    94111              <xsl:variable name="dcr_termset" select="document(url)" />           
    95112                  <xsl:apply-templates select="$dcr_termset" mode="dcr" >
     113                      <xsl:with-param name="config-node" select="."></xsl:with-param>
    96114                      <xsl:with-param name="set" select="key"></xsl:with-param>
    97115                  </xsl:apply-templates>             
     
    100118    </xsl:template>
    101119
     120       
    102121<!-- invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[] -->
    103122<xsl:template name="dcr-cmd-map">
     
    105124        <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
    106125            <Concept id="{@datcat}" type="datcat">
    107                 <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" />               
     126                <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" exclude-result-prefixes="my" />               
    108127                <xsl:for-each select="current-group()">
    109128                    <xsl:variable name="parent_profile" select="ancestor::Termset[@type='CMD_Profile']/@id" />
     
    154173</xsl:template>
    155174
     175<!-- load relation sets from the configuration and transform into Termset/Relation/Concepet
     176        (uses mode=rr-templates in dcr_rdf2terms.xsl)       -->
     177    <xsl:template name="load-rr-relations">
     178        <Termsets type="rr">
     179            <xsl:for-each select="$termsets_config//*[type='rr']" >
     180                <xsl:variable name="rr_termset" select="document(url)" />           
     181                <xsl:apply-templates select="$rr_termset" mode="rr" >
     182                    <xsl:with-param name="set" select="key"></xsl:with-param>
     183                </xsl:apply-templates>             
     184            </xsl:for-each>
     185        </Termsets>
     186    </xsl:template>
     187
     188<!-- take the rr-relations and expand them with data from dcr-cmd-terms,
     189    to get rr-expanded terms      -->
     190    <xsl:template name="rr-terms">       
     191            <xsl:apply-templates select="$rr-relations" mode="rr-expand" ></xsl:apply-templates>             
     192    </xsl:template>
     193   
     194    <xsl:template match="*" mode="rr-expand">
     195        <xsl:copy>
     196            <xsl:copy-of select="@*" />
     197            <xsl:apply-templates mode="rr-expand"></xsl:apply-templates>
     198        </xsl:copy>
     199    </xsl:template>
     200    <!-- expand rr-concepts-->
     201    <xsl:template match="Concept" mode="rr-expand">
     202        <xsl:variable name="concept-id" select="@id" />               
     203        <xsl:copy>
     204            <xsl:copy-of select="@*" />           
     205            <xsl:copy-of select="$dcr-cmd-map//Concept[@id=$concept-id]/Term" />           
     206        </xsl:copy>       
     207    </xsl:template>
     208   
    156209<!-- return a property of a Termset from the configuration. -->   
    157210    <xsl:function name="my:config">
     
    160213        <xsl:value-of select="$termsets_config//*[key=$key]/*[name()=$property]"></xsl:value-of>
    161214    </xsl:function>
     215   
     216   
    162217</xsl:stylesheet>
Note: See TracChangeset for help on using the changeset viewer.