Changeset 3468 for SMC


Ignore:
Timestamp:
08/24/13 12:29:30 (11 years ago)
Author:
vronk
Message:

weaving in (private) profiles (but already used in mdrepo)
and postloading data categories used in cmd (but not in metadata-profile)

Location:
SMC/trunk/SMC/src/xsl
Files:
2 edited

Legend:

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

    r3439 r3468  
    22<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    33    xmlns:my="myFunctions" exclude-result-prefixes="xs my" version="2.0">
     4   
     5    <xsl:output method="xml" indent="yes" exclude-result-prefixes="#all" name="xml"/>
     6   
    47   
    58    <xsl:include href="smc_params.xsl"/>
     
    912    <xsl:include href="dcr_dcif2terms.xsl"/>
    1013   
    11     <xsl:output method="xml" indent="yes" exclude-result-prefixes="#all" name="xml"/>
    1214   
    1315    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     
    3234   
    3335<!-- intermediate datasets bound into variables,to prevent calling the function every time -->
     36    <xsl:variable name="dcr-terms-preload" select="my:getData('dcr-terms-preload')" />
    3437   <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" />
    3538    <xsl:variable name="rr-relations" select="my:getData('rr-relations')" />
     
    4043   <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" />
    4144   <xsl:variable name="isocat-languages" select="my:getData('isocat-languages')" />
    42    
     45
     46    <xsl:key name="concept-id" match="Concept" use="xs:string(@id)" />
     47
    4348    <!--  -->
    4449   
     
    6368        <xsl:message><xsl:value-of select="$cache_path" /> available <xsl:value-of select="doc-available($cache_path)" /></xsl:message>
    6469<!--        <xsl:message>cachePath: <xsl:value-of select="$cache_path"></xsl:value-of></xsl:message>-->
    65             <xsl:if test="$cache='refresh' and not(doc-available($cache_path))">
    66                      
     70            <xsl:if test="contains($cache,'refresh') and not(doc-available($cache_path))">
    6771             <xsl:result-document href="{$cache_path}" format="xml" >
    6872                 <xsl:copy-of select="$result" />
     
    7276       
    7377        <!-- only output to main result if cache is use (otherwise only write out to cache) -->
    74         <xsl:if test="$cache='use' and not(doc-available($cache_path))">
     78<!--        <xsl:if test="$cache='use' and not(doc-available($cache_path))">-->
     79            <xsl:if test="contains($cache,'use')">
    7580            <xsl:copy-of select="$result"></xsl:copy-of>
    7681        </xsl:if>
     
    99104      <xsl:variable name="cached_data_file" select="my:cachePath($key,$id)"></xsl:variable>
    100105                <xsl:message>cache: <xsl:value-of select="$cache" /></xsl:message>
     106                <xsl:message>key: <xsl:value-of select="$key"></xsl:value-of></xsl:message>
    101107                <xsl:message><xsl:value-of select="$cached_data_file" /> available <xsl:value-of select="doc-available($cached_data_file)" /></xsl:message>
     108     
    102109     
    103110        <xsl:choose>
     
    108115            </xsl:when>
    109116            <xsl:when test="$key='cmd-profiles-raw'">
    110                 <xsl:copy-of select="document(my:config('cmd-profiles','url'))" />               
    111             </xsl:when>
    112             <xsl:when test="$key='profiles' or $key='component'">
     117                 
     118                <xsl:variable name="cmd-profiles" select="document(my:config('cmd-profiles','url'))" />               
     119                <!-- integrate profiles that are already used in instance data, but not public - if appropriate config entry given -->
     120                <xsl:variable name="used-profiles" >
     121                    <xsl:if test="my:config('used-profiles','url') ne ''" >
     122                        <xsl:copy-of select="document(my:config('used-profiles','url'))" />                           
     123                    </xsl:if>                   
     124                </xsl:variable>
     125                <profileDescriptions>
     126<!--                    DEBUG:<xsl:value-of select="my:config('used-profiles','url')"></xsl:value-of>-->
     127                    <xsl:copy-of select="$cmd-profiles//profileDescription"  />
     128                    <xsl:copy-of select="$used-profiles//profileDescription[not(id = $cmd-profiles//profileDescription/id)]" />
     129                   
     130                </profileDescriptions>               
     131            </xsl:when>
     132            <xsl:when test="$key='profiles' or $key='datcats'">               
    113133                <xsl:copy-of select="my:getRawData($key, $id)" />               
    114134            </xsl:when>
     
    125145                <xsl:apply-templates select="$cmd-terms-nested" mode="min-context"></xsl:apply-templates>
    126146            </xsl:when>           
     147            <xsl:when test="$key='dcr-terms-preload'">
     148                <xsl:call-template name="load-dcr" />                                                           
     149            </xsl:when>
    127150            <xsl:when test="$key='dcr-terms'">
    128                 <xsl:call-template name="load-dcr" />                                                           
     151                <xsl:call-template name="postload-datcats" />                                                           
    129152            </xsl:when>
    130153            <xsl:when test="$key='rr-relations'">
     
    154177   
    155178    </xsl:function>
    156    
    157     <!-- overload method with one param and value of global cache-param as default -->   
     179       
     180    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     181        <xd:desc>
     182            <xd:p>overload method with one param and value of global cache-param as default</xd:p>
     183        </xd:desc>
     184        <xd:param name="key"></xd:param>
     185    </xd:doc>
    158186    <xsl:function name="my:getData">
    159187        <xsl:param name="key"></xsl:param>
     
    166194        <xsl:copy-of select="my:getData($key,$id, $cache)"></xsl:copy-of>
    167195    </xsl:function>
    168    
    169   <!-- get the raw xml for a specific piece of data (profile, component, later data category) from the source -->
     196   
     197    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     198        <xd:desc>
     199            <xd:p>get the raw xml for a specific piece of data (profile, component, later data category) from the source, or from the cache if already available</xd:p>
     200            <xd:p>Storing to cache happens in load-profiles template</xd:p>
     201        </xd:desc>
     202        <xd:param name="key">currently only 'profiles'</xd:param>
     203        <xd:param name="id">id for the profile</xd:param>
     204    </xd:doc>
    170205    <xsl:function name="my:getRawData">
    171206        <xsl:param name="key"></xsl:param>
     
    183218       
    184219        -->
    185         <xsl:variable name="resolved_uri" select="if (doc-available($cached_data_file)) then $cached_data_file else concat($cmd_profiles_uri , $id, '/xml')" />
     220        <xsl:variable name="resolved_uri" select="if (doc-available($cached_data_file)) then $cached_data_file else concat($cmd_profiles_uri[$key='profiles'] , $id, '/xml'[$key='profiles'], '.dcif'[$key='datcats'])" />
    186221       
    187222        <xsl:message><xsl:value-of select="$key" />:</xsl:message>
     
    194229    </xsl:function>
    195230   
    196 
    197 <!-- load all dcrs from the configuration and transform them into Termsets
    198        (uses mode=dcr-templates in dcr_rdf2terms.xsl)       -->
     231    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     232        <xd:desc>
     233            <xd:p>load all dcrs from the configuration and transform them into Termsets
     234                (uses mode=dcr-templates in dcr_rdf2terms.xsl)</xd:p>
     235        </xd:desc>
     236    </xd:doc>
    199237    <xsl:template name="load-dcr">
    200238        <Termsets type="dcr">
     
    202240              <xsl:variable name="dcr_termset" select="document(url)" />           
    203241                  <xsl:apply-templates select="$dcr_termset" mode="dcr" >
    204                       <xsl:with-param name="config-node" select="."></xsl:with-param>
     242                      <xsl:with-param name="config-node" select="." />                                               
    205243                      <xsl:with-param name="set" select="key"></xsl:with-param>
    206244                  </xsl:apply-templates>             
    207           </xsl:for-each>
     245          </xsl:for-each>           
    208246        </Termsets>
    209247    </xsl:template>
    210 
    211     <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
    212         <xd:desc>
    213             <xd:p>stores all profiles in the cache, by calling getData-template with $cache=refresh param</xd:p>
    214         </xd:desc>
    215     </xd:doc>
     248   
     249   
     250    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     251        <xd:desc>
     252            <xd:p>load all data-categories, that are used in CMD, and are not present in the Termsets already downloaded in load-dcr</xd:p>
     253        </xd:desc>
     254    </xd:doc>
     255    <xsl:template name="postload-datcats">
     256       
     257        <xsl:variable name="missing-datcats" select="distinct-values($cmd-terms//Term[not(@datcat='')][not(@datcat =$dcr-terms-preload//Concept/@id)]/@datcat)" />
     258        <xsl:for-each select="$missing-datcats">
     259<!--            <xsl:copy-of select="my:getRawData('datcats',.)" />-->
     260                <xsl:call-template name="getData">
     261                    <xsl:with-param name="key" select="'datcats'"></xsl:with-param>
     262                    <!--<xsl:with-param name="id" select="my:shortURL(.)"></xsl:with-param>-->
     263                    <xsl:with-param name="id" select="."></xsl:with-param>
     264                    <xsl:with-param name="cache" select="'refresh'"></xsl:with-param>
     265                </xsl:call-template>
     266        </xsl:for-each>
     267       
     268        <xsl:variable name="resolved_datcats">
     269        <xsl:for-each select="$missing-datcats">
     270            <!--            <xsl:copy-of select="my:getRawData('datcats',.)" />-->
     271            <xsl:apply-templates select="my:getData('datcats',.)" mode="dcr" >           
     272                <xsl:with-param name="config-node" >
     273                <item>
     274                    <name>ISOcat</name>
     275                    <url_prefix>http://www.isocat.org/datcat/</url_prefix>
     276                </item>
     277                </xsl:with-param>
     278                <xsl:with-param name="set" select="'isocat'"></xsl:with-param>
     279            </xsl:apply-templates>
     280        </xsl:for-each>
     281        </xsl:variable>
     282        <!-- weave in the newly generated missing dcr-terms inton the isocat termset-->
     283       
     284            <Termsets type="dcr">
     285                <Termset>
     286                    <xsl:copy-of select="$dcr-terms-preload//Termset[xs:string(@set)='isocat']/@*"/>
     287                    <xsl:copy-of select="$dcr-terms-preload//Termset[xs:string(@set)='isocat']/*" />
     288                    <xsl:copy-of select="$resolved_datcats/Termset[xs:string(@set)='isocat']/*" />
     289                </Termset>
     290                <xsl:copy-of select="$dcr-terms-preload//Termset[xs:string(@set) ne 'isocat']" />     
     291            </Termsets>
     292
     293<!--        <xsl:copy-of select="$raw-datcat-defs"></xsl:copy-of>-->
     294        <!--    <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
     295                    <xsl:variable name="curr_datcat" select="@datcat" />
     296                <xsl:value-of select="$curr_datcat"></xsl:value-of>
     297                #<xsl:copy-of select="$dcr-terms-preload//key('concept-id',$curr_datcat)"></xsl:copy-of>-               
     298            </xsl:for-each-group>-->               
     299<!--        [not(exists($dcr-terms-preload/key('concept-id',@datcat)))]-->
     300<!--        </xsl:variable>-->
     301<!--        <xsl:value-of select="$missing-datcats" />-->
     302        <!--<xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
     303            <Concept id="{@datcat}" type="datcat">
     304                <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" exclude-result-prefixes="my" />
     305               
     306        -->
     307<!--        <Termsets type="dcr">
     308            <xsl:for-each select="$termsets_config//*[type='dcr']" >
     309                <xsl:variable name="dcr_termset" select="document(url)" />           
     310                <xsl:apply-templates select="$dcr_termset" mode="dcr" >
     311                    <xsl:with-param name="config-node" select="."></xsl:with-param>
     312                    <xsl:with-param name="set" select="key"></xsl:with-param>
     313                </xsl:apply-templates>             
     314            </xsl:for-each>           
     315        </Termsets>
     316    </xsl:template>
     317
     318
    216319    <xsl:template name="load-profiles">
    217320       
    218 <!--        <xsl:variable name="profiles" select="document(my:config('cmd-profiles','url'))"></xsl:variable>-->
     321        <!-\-        <xsl:variable name="profiles" select="document(my:config('cmd-profiles','url'))"></xsl:variable>-\->
    219322        <xsl:variable name="profiles" select="my:getData('cmd-profiles-raw')"></xsl:variable>
    220323       
    221 <!-- ???        <xsl:apply-templates select="$profiles" mode="include" />-->
     324        <!-\- ???        <xsl:apply-templates select="$profiles" mode="include" />-\->
    222325       
    223326        <xsl:for-each select="$profiles//profileDescription[id]">
     
    228331            </xsl:call-template>
    229332        </xsl:for-each>
     333-->       
     334    </xsl:template>
     335
     336
     337    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     338        <xd:desc>
     339            <xd:p>stores all profiles in the cache, by calling getData-template with $cache=refresh param</xd:p>
     340        </xd:desc>
     341    </xd:doc>
     342    <xsl:template name="load-profiles">
     343       
     344<!--        <xsl:variable name="profiles" select="document(my:config('cmd-profiles','url'))"></xsl:variable>-->
     345        <xsl:variable name="profiles" select="my:getData('cmd-profiles-raw')"></xsl:variable>
     346       
     347<!-- ???        <xsl:apply-templates select="$profiles" mode="include" />-->
     348       
     349        <xsl:for-each select="$profiles//profileDescription[id]">
     350            <xsl:call-template name="getData">
     351                <xsl:with-param name="key" select="'profiles'"></xsl:with-param>
     352                <xsl:with-param name="id" select="id"></xsl:with-param>
     353                <xsl:with-param name="cache" select="'refresh'"></xsl:with-param>
     354            </xsl:call-template>
     355        </xsl:for-each>
    230356       
    231357    </xsl:template>
     
    237363    </xd:doc>
    238364<xsl:template name="dcr-cmd-map">
     365    <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" />
    239366    <Termset type="dcr-cmd-map" >       
    240367        <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
  • SMC/trunk/SMC/src/xsl/smc_init.xsl

    r3440 r3468  
    6262  <xsl:call-template name="load-profiles"></xsl:call-template>
    6363 </xsl:when>
     64 <xsl:when test="$data_key = 'dcr-terms'">
     65  <xsl:call-template name="postload-datcats" />
     66 </xsl:when>
    6467 <xsl:otherwise>
    6568  <xsl:call-template name="getData">
Note: See TracChangeset for help on using the changeset viewer.