- Timestamp:
- 08/20/13 11:52:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SMC/trunk/SMC/src/xsl/smc_commons.xsl
r2437 r3439 8 8 <xsl:include href="dcr_rdf2terms.xsl"/> 9 9 <xsl:include href="dcr_dcif2terms.xsl"/> 10 11 <!-- use either input (precedence) or the config-file as the termsets configuration --> 10 11 <xsl:output method="xml" indent="yes" exclude-result-prefixes="#all" name="xml"/> 12 13 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 14 <xd:desc> 15 <xd:p>use either input (precedence) or the config-file as the termsets configuration</xd:p> 16 </xd:desc> 17 </xd:doc> 12 18 <xsl:variable name="termsets_config"> 13 19 <xsl:choose> … … 23 29 <!-- needed in cmd_includes.xsl --> 24 30 <xsl:variable name="cmd_components_uri" select="my:config('cmd-components','url')" /> 25 <xsl:variable name="cmd_profiles_uri" select="my:config('cmd-profiles','url ')" />31 <xsl:variable name="cmd_profiles_uri" select="my:config('cmd-profiles','url_prefix')" /> 26 32 27 33 <!-- intermediate datasets bound into variables,to prevent calling the function every time --> … … 35 41 <xsl:variable name="isocat-languages" select="my:getData('isocat-languages')" /> 36 42 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) --> 43 <!-- --> 44 45 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 46 <xd:desc> 47 <xd:p>either serves a dataset or invokes its generation and stores to cache, based on the cache parameter</xd:p> 48 <xd:p>passes down to my:getData() function for actual generation of the dataset</xd:p> 49 </xd:desc> 50 <xd:param name="key">dataset key</xd:param> 51 <xd:param name="id">optional profile or component identifier to retrieve a single profile or component</xd:param> 52 <xd:param name="cache">use: returns the requested dataset, refresh: writes the dataset to cache (overwriting)</xd:param> 53 </xd:doc> 54 <xsl:template name="getData"> 55 <xsl:param name="key" select="$data_key"></xsl:param> 56 <xsl:param name="id" select="$id"></xsl:param> 57 <xsl:param name="cache" select="$cache"></xsl:param> 58 59 <xsl:variable name="cache_path" select="my:cachePath($key,$id)" /> 60 <!--<xsl:message>document-uri1: <xsl:value-of select="document-uri(/)"></xsl:value-of></xsl:message>--> 61 <xsl:variable name="result" select="my:getData($key,$id,$cache)"></xsl:variable> 62 63 <xsl:message><xsl:value-of select="$cache_path" /> available <xsl:value-of select="doc-available($cache_path)" /></xsl:message> 64 <!-- <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 67 <xsl:result-document href="{$cache_path}" format="xml" > 68 <xsl:copy-of select="$result" /> 69 </xsl:result-document> 70 </xsl:if> 71 72 73 <!-- 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))"> 75 <xsl:copy-of select="$result"></xsl:copy-of> 76 </xsl:if> 77 78 </xsl:template> 79 80 <!-- 81 --> 82 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 83 <xd:desc> 84 <xd:p>serves individual datasets (cmd-profiles, dcr-termsets...)</xd:p> 85 <xd:p>primitive cache mechanism - 86 if data of given key is already stored, serve it, 87 otherwise build a new (but don't store in cache - within this function) 88 </xd:p> 89 </xd:desc> 90 <xd:param name="key">dataset key</xd:param> 91 <xd:param name="id">optional profile or component identifier to retrieve a single profile or component</xd:param> 92 <xd:param name="cache">recognized value: use beware of the param-value in recursive calls (currently 'use' is fixed for deeper calls)</xd:param> 93 </xd:doc> 42 94 <xsl:function name="my:getData"> 43 95 <xsl:param name="key"></xsl:param> 44 <xsl:param name=" cache"></xsl:param>45 46 <xsl:variable name="cached_data_file" select="concat($cache_dir, if (ends-with($cache_dir,'/') or ends-with($cache_dir,'\')) then '' else '/',47 $key, '.xml')"></xsl:variable>96 <xsl:param name="id"></xsl:param> 97 <xsl:param name="cache"></xsl:param> 98 99 <xsl:variable name="cached_data_file" select="my:cachePath($key,$id)"></xsl:variable> 48 100 <xsl:message>cache: <xsl:value-of select="$cache" /></xsl:message> 49 101 <xsl:message><xsl:value-of select="$cached_data_file" /> available <xsl:value-of select="doc-available($cached_data_file)" /></xsl:message> 102 50 103 <xsl:choose> 51 104 <xsl:when test="doc-available($cached_data_file) and $cache='use'"> … … 57 110 <xsl:copy-of select="document(my:config('cmd-profiles','url'))" /> 58 111 </xsl:when> 112 <xsl:when test="$key='profiles' or $key='component'"> 113 <xsl:copy-of select="my:getRawData($key, $id)" /> 114 </xsl:when> 59 115 <xsl:when test="$key='cmd-resolved'"> 60 116 <xsl:apply-templates select="my:getData('cmd-profiles-raw')" mode="include" /> … … 95 151 </xsl:otherwise> 96 152 </xsl:choose> 153 154 97 155 </xsl:function> 98 156 … … 100 158 <xsl:function name="my:getData"> 101 159 <xsl:param name="key"></xsl:param> 102 <xsl:copy-of select="my:getData($key,$cache)"></xsl:copy-of> 103 </xsl:function> 104 160 <xsl:copy-of select="my:getData($key,'', $cache)"></xsl:copy-of> 161 </xsl:function> 162 163 <xsl:function name="my:getData"> 164 <xsl:param name="key"></xsl:param> 165 <xsl:param name="id"></xsl:param> 166 <xsl:copy-of select="my:getData($key,$id, $cache)"></xsl:copy-of> 167 </xsl:function> 168 169 <!-- get the raw xml for a specific piece of data (profile, component, later data category) from the source --> 170 <xsl:function name="my:getRawData"> 171 <xsl:param name="key"></xsl:param> 172 <xsl:param name="id"></xsl:param> 173 174 <xsl:variable name="cached_data_file" select="my:cachePath($key,$id)"></xsl:variable> 175 <!-- <xsl:variable name="cached_data_file" select="concat($cache_dir, if (ends-with($cache_dir,'/') or ends-with($cache_dir,'\')) then '' else '/', 176 $key, '/', my:normalize($id), '.xml')"></xsl:variable>--> 177 <!-- <xsl:message>cache: <xsl:value-of select="$cache" /></xsl:message> 178 <xsl:message><xsl:value-of select="$cached_data_file" /> available <xsl:value-of select="doc-available($cached_data_file)" /></xsl:message> 179 --> 180 181 <!--<xsl:variable name="resolved_fn" select="concat($cmd_components_uri, @ComponentId)" /> 182 <xsl:variable name="compid" select="@ComponentId" /> 183 184 --> 185 <xsl:variable name="resolved_uri" select="if (doc-available($cached_data_file)) then $cached_data_file else concat($cmd_profiles_uri , $id, '/xml')" /> 186 187 <xsl:message><xsl:value-of select="$key" />:</xsl:message> 188 <xsl:message>resolved_uri:<xsl:value-of select="$resolved_uri" /></xsl:message> 189 <xsl:if test="doc-available($resolved_uri)"> 190 <xsl:copy-of select="doc($resolved_uri)" /> 191 <!-- <xsl:apply-templates select="document($resolved_uri)" mode="include" />--> 192 </xsl:if> 193 194 </xsl:function> 195 196 105 197 <!-- load all dcrs from the configuration and transform them into Termsets 106 198 (uses mode=dcr-templates in dcr_rdf2terms.xsl) --> … … 117 209 </xsl:template> 118 210 119 120 <!-- invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[] --> 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> 216 <xsl:template name="load-profiles"> 217 218 <!-- <xsl:variable name="profiles" select="document(my:config('cmd-profiles','url'))"></xsl:variable>--> 219 <xsl:variable name="profiles" select="my:getData('cmd-profiles-raw')"></xsl:variable> 220 221 <!-- ??? <xsl:apply-templates select="$profiles" mode="include" />--> 222 223 <xsl:for-each select="$profiles//profileDescription[id]"> 224 <xsl:call-template name="getData"> 225 <xsl:with-param name="key" select="'profiles'"></xsl:with-param> 226 <xsl:with-param name="id" select="id"></xsl:with-param> 227 <xsl:with-param name="cache" select="'refresh'"></xsl:with-param> 228 </xsl:call-template> 229 </xsl:for-each> 230 231 </xsl:template> 232 233 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 234 <xd:desc> 235 <xd:p>invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[]</xd:p> 236 </xd:desc> 237 </xd:doc> 121 238 <xsl:template name="dcr-cmd-map"> 122 239 <Termset type="dcr-cmd-map" > … … 132 249 </xsl:for-each-group> 133 250 </Termset> 134 </xsl:template> 135 136 <!-- list dcr-termsets + cmd (+ cmd-profiles) 137 TODO: missing: isocat@langs, RR-sets --> 251 </xsl:template> 252 253 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 254 <xd:desc> 255 <xd:p>list dcr-termsets + cmd (+ cmd-profiles)</xd:p> 256 <xd:p>TODO: missing: isocat@langs, RR-sets</xd:p> 257 </xd:desc> 258 </xd:doc> 138 259 <xsl:template name="termsets"> 139 260 <Termsets type="list"> … … 172 293 </xsl:template> 173 294 174 <!-- load relation sets from the configuration and transform into Termset/Relation/Concepet 175 (uses mode=rr-templates in dcr_rdf2terms.xsl) --> 295 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 296 <xd:desc> 297 <xd:p>load relation sets from the configuration and transform into Termset/Relation/Concepet 298 (uses mode=rr-templates in dcr_rdf2terms.xsl) </xd:p> 299 </xd:desc> 300 </xd:doc> 176 301 <xsl:template name="load-rr-relations"> 177 302 <Termsets type="rr"> … … 185 310 </xsl:template> 186 311 187 <!-- take the rr-relations and expand them with data from dcr-cmd-terms, 188 to get rr-expanded terms --> 312 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 313 <xd:desc> 314 <xd:p>take the rr-relations and expand them with data from dcr-cmd-terms, 315 to get rr-expanded terms</xd:p> 316 </xd:desc> 317 </xd:doc> 189 318 <xsl:template name="rr-terms"> 190 319 <xsl:apply-templates select="$rr-relations" mode="rr-expand" ></xsl:apply-templates> … … 197 326 </xsl:copy> 198 327 </xsl:template> 199 <!-- expand rr-concepts--> 328 329 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 330 <xd:desc> 331 <xd:p>expand rr-concepts</xd:p> 332 </xd:desc> 333 </xd:doc> 200 334 <xsl:template match="Concept" mode="rr-expand"> 201 335 <xsl:variable name="concept-id" select="@id" /> … … 205 339 </xsl:copy> 206 340 </xsl:template> 207 208 <!-- return a property of a Termset from the configuration. --> 341 342 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 343 <xd:desc> 344 <xd:p>return a property of a Termset from the configuration.</xd:p> 345 </xd:desc> 346 <xd:param name="key">key identifying the dataset item</xd:param> 347 <xd:param name="property">element-name of the requested property</xd:param> 348 </xd:doc> 209 349 <xsl:function name="my:config"> 210 350 <xsl:param name="key"></xsl:param>
Note: See TracChangeset
for help on using the changeset viewer.