Changeset 1671 for SMC


Ignore:
Timestamp:
12/16/11 20:20:28 (12 years ago)
Author:
vronk
Message:

implementing isocat-languages as termsets

Location:
SMC/trunk/SMC/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/eu/clarin/cmdi/smc/SMC.java

    r1660 r1671  
    262262                transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader());
    263263               
    264                
     264                log.debug("term: " + term);
    265265                addParam("operation", "map");
    266266                addParam("term", term);
  • SMC/trunk/SMC/src/scripts/smc_commons.xsl

    r1653 r1671  
    11<?xml version="1.0" encoding="UTF-8"?>
    2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    3     xmlns:xs="http://www.w3.org/2001/XMLSchema"
    4     xmlns:my="myFunctions"
    5     exclude-result-prefixes="xs"
    6     version="2.0">
     2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
     3    xmlns:my="myFunctions" exclude-result-prefixes="xs my" version="2.0">
    74   
    85    <xsl:include href="smc_params.xsl"/>
     
    2623   <xsl:variable name="cmd_components_uri" select="my:config('cmd-components','url')" />
    2724   <xsl:variable name="cmd_profiles_uri" select="my:config('cmd-profiles','url')" />
    28 
    29 <!-- intermediate datasets bound into variables,to prevent calling the function every time -->
    3025   
     26<!-- intermediate datasets bound into variables,to prevent calling the function every time -->
    3127   <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" />
    3228   <xsl:variable name="cmd-terms" select="my:getData('cmd-terms')" />
    3329   <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" />
    34 
     30   <xsl:variable name="isocat-languages" select="my:getData('isocat-languages')" />
    3531   
    36     <!--
    37         serves individual datasets (cmd-profiles, dcr-termsets...)
     32 <!-- serves individual datasets (cmd-profiles, dcr-termsets...)
    3833        primitive cache mechanism -
    3934        if data of given key is already stored, serve it,
    4035        otherwise build a new (but don't store in cache - within this function)
    41         regard the cache-param - beware of the param-value in recursive calls (currently 'use' is fixed for deeper calls) 
    42     -->
    43    
    44     <xsl:function name="my:getData">
     36        regard the cache-param - beware of the param-value in recursive calls (currently 'use' is fixed for deeper calls)     -->
     37  <xsl:function name="my:getData">
    4538        <xsl:param name="key"></xsl:param>
    4639        <xsl:param name="cache"></xsl:param>
     
    7265                <xsl:call-template name="termsets" />                                                           
    7366            </xsl:when>
     67            <xsl:when test="$key='isocat-languages'">
     68                <xsl:copy-of select="document(my:config('isocat-languages','url'))" />                                                         
     69            </xsl:when>
    7470            <xsl:when test="$key='dcr-cmd-map'">
    7571                <xsl:call-template name="dcr-cmd-map" />
     
    8278                <diagnostics>unknown data: <xsl:value-of select="$key" /></diagnostics>
    8379            </xsl:otherwise>
    84         </xsl:choose>
    85        
     80        </xsl:choose>   
    8681    </xsl:function>
    8782   
     
    9287    </xsl:function>
    9388   
    94 
    9589<!-- load all dcrs from the configuration and transform them into Termsets
    96        (uses mode=dcr-templates in dcr_rdf2terms.xsl)   
    97    -->
     90       (uses mode=dcr-templates in dcr_rdf2terms.xsl)       -->
    9891    <xsl:template name="load-dcr">
    9992        <Termsets type="dcr">
     
    10295                  <xsl:apply-templates select="$dcr_termset" mode="dcr" >
    10396                      <xsl:with-param name="set" select="key"></xsl:with-param>
    104                   </xsl:apply-templates>
    105              
     97                  </xsl:apply-templates>             
    10698          </xsl:for-each>
    10799        </Termsets>
    108100    </xsl:template>
    109101
    110 <!--
    111     invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[]
    112 -->     
     102<!-- invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[] -->
    113103<xsl:template name="dcr-cmd-map">
    114104    <Termset type="dcr-cmd-map" >       
    115105        <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
    116106            <Concept id="{@datcat}" type="datcat">
    117                 <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" />
    118                
     107                <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" />               
    119108                <xsl:for-each select="current-group()">
    120109                    <xsl:variable name="parent_profile" select="ancestor::Termset[@type='CMD_Profile']/@id" />
     
    129118<!-- list dcr-termsets + cmd (+ cmd-profiles)
    130119TODO: missing: isocat@langs, RR-sets -->   
    131 <xsl:template name="termsets">
     120<xsl:template name="termsets">   
    132121    <Termsets type="list">
    133122        <!-- add dcr-termsets directly from config -->
    134         <xsl:for-each select="$termsets_config//*[type='dcr']" >
     123        <xsl:for-each select="$termsets_config//*[type='dcr'][not(key='isocat')]" >
    135124            <Termset>
    136125                <xsl:copy-of select="*" />
    137126            </Termset>                       
     127        </xsl:for-each>       
     128        <xsl:for-each select="$termsets_config//*[type='dcr'][key='isocat']" >
     129            <Termset>
     130                <xsl:copy-of select="*" />
     131                <xsl:for-each select="$isocat-languages/languages/language" >
     132                    <Termset>
     133<!--                        name="Finnish" search="finnish" tag="fi"-->
     134                        <key>isocat-<xsl:value-of select="@tag"></xsl:value-of></key>                       
     135                        <name>ISOcat <xsl:value-of select="@name"></xsl:value-of></name>
     136                    </Termset>
     137                </xsl:for-each>
     138            </Termset>                       
    138139        </xsl:for-each>
     140       
    139141        <Termset type="cmd">
    140142          <xsl:for-each select="$cmd-terms//Termset" >
     
    152154</xsl:template>
    153155
    154 <!--
    155     return a property of a Termset from the configuration.
    156 -->   
     156<!-- return a property of a Termset from the configuration. -->   
    157157    <xsl:function name="my:config">
    158158        <xsl:param name="key"></xsl:param>
     
    160160        <xsl:value-of select="$termsets_config//*[key=$key]/*[name()=$property]"></xsl:value-of>
    161161    </xsl:function>
    162    
    163    
    164162</xsl:stylesheet>
  • SMC/trunk/SMC/src/scripts/smc_params.xsl

    r1665 r1671  
    99   
    1010    <!-- used to config smc_init.xsl --> 
    11     <!-- allowed values:  cmd-profiles-raw , cmd-resolved, cmd-terms, dcr-terms, dcr-cmd-map -->
     11    <!-- allowed values:  cmd-profiles-raw , cmd-resolved, cmd-terms, dcr-terms, dcr-cmd-map, isocat-languages -->
    1212    <xsl:param name="data_key" select="'termsets'" />
    1313   
     
    1515    <xsl:param name="cache" select="'use'" />
    1616<!--    <xsl:param name="cache_dir" select="'file:/C:/Users/m/3lingua/clarin/CMDI/SMC/cache/'" />-->
    17     <xsl:variable name="cache_dir" select="'file:/C:/Users/m/3lingua/clarin/CMDI/SMC/cache/'" />
    18    
     17    <xsl:variable name="cache_dir" select="'file:/C:/Users/m/3lingua/clarin/CMDI/_repo2/SMC/data/'" />   
    1918</xsl:stylesheet>
  • SMC/trunk/SMC/src/smc_config.xml

    r1665 r1671  
    3030   </item>
    3131   <item>
     32      <!-- no "standard" type, because this is for special handling of isocat -->
     33      <type>dcrx</type>
     34      <key>isocat-languages</key>
     35      <name>ISOcat Languages</name>
     36      <url>http://www.isocat.org/rest/info/languages.xml</url>     
     37      <url_prefix></url_prefix>
     38      <format>rdf</format>
     39   </item>
     40   <item>
    3241      <type>dcr</type>
    3342      <key>dce</key>
Note: See TracChangeset for help on using the changeset viewer.