Changeset 1652


Ignore:
Timestamp:
12/09/11 22:00:47 (12 years ago)
Author:
vronk
Message:

minors + correcting my:config()-function (match on key-element instead of id-element)

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

Legend:

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

    r1650 r1652  
    5151                SMC smc = new SMC();
    5252
    53                 //smc.init();           
    54                
    55                 InputStream is = smc.listTermsets("");
    56                 String output_path = Utils.getConfig("cache.dir") +  smc.getParam("data_key") + "_.xml" ;               
     53                smc.init();             
     54               
     55//              InputStream is = smc.listTerms("isocat");
     56                /* InputStream is = smc.map("nome do projecto");
     57                String output_path = Utils.getConfig("cache.dir") +  "test_res_map.xml" ;               
    5758                File f = Utils.write2File(output_path, is);
    5859                log.debug("result stored in: " + f.getAbsolutePath());
    59 
     60*/
    6061        }
    6162
     
    9091                // TODO: WHY??
    9192                //transformer.setSrcFile(Utils.getConfig("termsets.config.file"));
    92                 addParam("data_key", "dcr-cmd-map");
     93        //      addParam("data_key", "dcr-cmd-map");
     94                addParam("data_key", "cmd-profiles-raw");
    9395
    9496                // this is necessary for the transformer (in MDUTILS-library) to search for the resources (config and xsls) in the correct context)
     
    223225               
    224226                addParam("set", context);
     227                addParam("term", "*");
    225228                 
    226229                transformer.setParams(getParams());             
    227                 transformer.setTranskey("op");
     230                transformer.setTranskey("list");
    228231
    229232                InputStream resultStream=null;
     
    258261                transformer.configure(Utils.getAppConfig(appname), this.getClass().getClassLoader());
    259262               
    260                 // set URL as srcFile (for MDTransformer to pass to xsl-scripts)
    261                 // TODO: WHY??
    262                 //transformer.setSrcFile(Utils.getConfig("termsets.config.file"));
    263                
    264263                addParam("term", term);
    265264                 
    266265                transformer.setParams(getParams());             
    267                 transformer.setTranskey("op");
     266                transformer.setTranskey("map");
    268267
    269268                InputStream resultStream=null;
  • SMC/trunk/SMC/src/scripts/smc_commons.xsl

    r1607 r1652  
    3232   <xsl:variable name="cmd-terms" select="my:getData('cmd-terms')" />
    3333   <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" />
     34
    3435   
     36    <!--
     37        serves individual datasets (cmd-profiles, dcr-termsets...)
     38        primitive cache mechanism -
     39        if data of given key is already stored, serve it,
     40        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">
     45        <xsl:param name="key"></xsl:param>
     46        <xsl:param name="cache"></xsl:param>
     47       
     48        <xsl:variable name="cached_data_file" select="concat($cache_dir, $key, '.xml')"></xsl:variable>
     49        <xsl:message>
     50            cache: <xsl:value-of select="$cache" />
     51            <xsl:value-of select="$cached_data_file" />: <xsl:value-of select="doc-available($cached_data_file)" />
     52        </xsl:message>
     53        <xsl:choose>
     54            <xsl:when test="doc-available($cached_data_file) and $cache='use'">
     55                <xsl:message>reading in: <xsl:value-of select="$cached_data_file" />                   
     56                </xsl:message>
     57                <xsl:copy-of select="document($cached_data_file)"></xsl:copy-of>
     58            </xsl:when>
     59            <xsl:when test="$key='cmd-profiles-raw'">
     60                <xsl:copy-of select="document(my:config('cmd-profiles','url'))" />               
     61            </xsl:when>
     62            <xsl:when test="$key='cmd-resolved'">
     63                <xsl:apply-templates select="my:getData('cmd-profiles')" mode="include" />               
     64            </xsl:when>
     65            <xsl:when test="$key='cmd-terms'">
     66                <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription)" />
     67            </xsl:when>
     68            <xsl:when test="$key='dcr-terms'">
     69                <xsl:call-template name="load-dcr" />                                                           
     70            </xsl:when>
     71            <xsl:when test="$key='termsets'">
     72                <xsl:call-template name="termsets" />                                                           
     73            </xsl:when>
     74            <xsl:when test="$key='dcr-cmd-map'">
     75                <xsl:call-template name="dcr-cmd-map" />
     76            </xsl:when>
     77            <!-- for debugging -->
     78            <xsl:when test="$key='termsets-config'">
     79                <xsl:copy-of select="$termsets_config" />                                                               
     80            </xsl:when>
     81            <xsl:otherwise>     
     82                <diagnostics>unknown data: <xsl:value-of select="$key" /></diagnostics>
     83            </xsl:otherwise>
     84        </xsl:choose>
     85       
     86    </xsl:function>
     87   
     88    <!-- overload method with one param and value of global cache-param as default -->   
     89    <xsl:function name="my:getData">
     90        <xsl:param name="key"></xsl:param>
     91        <xsl:copy-of select="my:getData($key,$cache)"></xsl:copy-of>
     92    </xsl:function>
     93   
     94
    3595<!-- load all dcrs from the configuration and transform them into Termsets
    3696       (uses mode=dcr-templates in dcr_rdf2terms.xsl)   
     
    96156-->   
    97157    <xsl:function name="my:config">
    98         <xsl:param name="id"></xsl:param>
     158        <xsl:param name="key"></xsl:param>
    99159        <xsl:param name="property"></xsl:param>
    100         <xsl:value-of select="$termsets_config//*[id=$id]/*[name()=$property]"></xsl:value-of>
    101     </xsl:function>
    102    
    103 <!-- overload method with one param and cache=use as default -->   
    104     <xsl:function name="my:getData">
    105         <xsl:param name="key"></xsl:param>
    106         <xsl:copy-of select="my:getData($key,'use')"></xsl:copy-of>
    107     </xsl:function>
    108  
    109     <!--
    110  serves individual datasets (cmd-profiles, dcr-termsets...)
    111     primitive cache mechanism -
    112     if data of given key is already stored, serve it,
    113     otherwise build a new (but don't store in cache - within this function)
    114     regard the cache-param - beware of the param-value in recursive calls (currently 'use' is fixed for deeper calls) 
    115  -->
    116        
    117     <xsl:function name="my:getData">
    118         <xsl:param name="key"></xsl:param>
    119         <xsl:param name="cache"></xsl:param>
    120        
    121         <xsl:variable name="cached_data_file" select="concat($cache_dir, $key, '.xml')"></xsl:variable>
    122         <xsl:message>
    123             <xsl:value-of select="$cached_data_file" />: <xsl:value-of select="doc-available($cached_data_file)" />
    124         </xsl:message>
    125         <xsl:choose>
    126             <xsl:when test="doc-available($cached_data_file) and $cache='use'">
    127                 <xsl:message>reading in: <xsl:value-of select="$cached_data_file" />                   
    128                 </xsl:message>
    129                 <xsl:copy-of select="document($cached_data_file)"></xsl:copy-of>
    130             </xsl:when>
    131             <xsl:when test="$key='cmd-profiles-raw'">
    132                 <xsl:copy-of select="document(my:config('cmd-profiles','url'))" />                     
    133             </xsl:when>
    134             <xsl:when test="$key='cmd-resolved'">
    135                 <xsl:apply-templates select="my:getData('cmd-profiles')" mode="include" />               
    136             </xsl:when>
    137             <xsl:when test="$key='cmd-terms'">
    138                 <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription)" />
    139             </xsl:when>
    140             <xsl:when test="$key='dcr-terms'">
    141                 <xsl:call-template name="load-dcr" />                                                           
    142             </xsl:when>
    143             <xsl:when test="$key='termsets'">
    144                 <xsl:call-template name="termsets" />                                                           
    145             </xsl:when>
    146             <xsl:when test="$key='dcr-cmd-map'">
    147                 <xsl:call-template name="dcr-cmd-map" />
    148             </xsl:when>                     
    149             <xsl:otherwise>     
    150                 <diagnostics>unknown data: <xsl:value-of select="$key" /></diagnostics>
    151             </xsl:otherwise>
    152         </xsl:choose>
    153        
     160        <xsl:value-of select="$termsets_config//*[key=$key]/*[name()=$property]"></xsl:value-of>
    154161    </xsl:function>
    155162   
  • SMC/trunk/SMC/src/scripts/smc_op.xsl

    r1650 r1652  
    1818   
    1919 <xsl:template match="/">
    20      <xsl:choose>     
     20     <xsl:choose>   
     21                <xsl:when test="not($term='')">
     22                 <xsl:variable name="matching_concepts" select="$dcr-cmd-map//Concept[Term=$term]"></xsl:variable>
     23                     <xsl:for-each select="$matching_concepts//Term[@set='cmd']">
     24                         <xsl:value-of select="." />;                     
     25                     </xsl:for-each>             
     26         </xsl:when> 
    2127     <!-- if $set=*, list all termsets -->
    2228         <xsl:when test="$set='*' or $set='top'">
  • SMC/trunk/SMC/src/smc.properties

    r1650 r1652  
    55scripts.path = scripts/
    66xsl.init = smc_init.xsl
     7xsl.list = smc_op.xsl
    78xsl.map = smc_op.xsl
Note: See TracChangeset for help on using the changeset viewer.