Changeset 3468
- Timestamp:
- 08/24/13 12:29:30 (11 years ago)
- Location:
- SMC/trunk/SMC/src/xsl
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
SMC/trunk/SMC/src/xsl/smc_commons.xsl
r3439 r3468 2 2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" 3 3 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 4 7 5 8 <xsl:include href="smc_params.xsl"/> … … 9 12 <xsl:include href="dcr_dcif2terms.xsl"/> 10 13 11 <xsl:output method="xml" indent="yes" exclude-result-prefixes="#all" name="xml"/>12 14 13 15 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> … … 32 34 33 35 <!-- 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')" /> 34 37 <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" /> 35 38 <xsl:variable name="rr-relations" select="my:getData('rr-relations')" /> … … 40 43 <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" /> 41 44 <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 43 48 <!-- --> 44 49 … … 63 68 <xsl:message><xsl:value-of select="$cache_path" /> available <xsl:value-of select="doc-available($cache_path)" /></xsl:message> 64 69 <!-- <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))"> 67 71 <xsl:result-document href="{$cache_path}" format="xml" > 68 72 <xsl:copy-of select="$result" /> … … 72 76 73 77 <!-- 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')"> 75 80 <xsl:copy-of select="$result"></xsl:copy-of> 76 81 </xsl:if> … … 99 104 <xsl:variable name="cached_data_file" select="my:cachePath($key,$id)"></xsl:variable> 100 105 <xsl:message>cache: <xsl:value-of select="$cache" /></xsl:message> 106 <xsl:message>key: <xsl:value-of select="$key"></xsl:value-of></xsl:message> 101 107 <xsl:message><xsl:value-of select="$cached_data_file" /> available <xsl:value-of select="doc-available($cached_data_file)" /></xsl:message> 108 102 109 103 110 <xsl:choose> … … 108 115 </xsl:when> 109 116 <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'"> 113 133 <xsl:copy-of select="my:getRawData($key, $id)" /> 114 134 </xsl:when> … … 125 145 <xsl:apply-templates select="$cmd-terms-nested" mode="min-context"></xsl:apply-templates> 126 146 </xsl:when> 147 <xsl:when test="$key='dcr-terms-preload'"> 148 <xsl:call-template name="load-dcr" /> 149 </xsl:when> 127 150 <xsl:when test="$key='dcr-terms'"> 128 <xsl:call-template name=" load-dcr" />151 <xsl:call-template name="postload-datcats" /> 129 152 </xsl:when> 130 153 <xsl:when test="$key='rr-relations'"> … … 154 177 155 178 </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> 158 186 <xsl:function name="my:getData"> 159 187 <xsl:param name="key"></xsl:param> … … 166 194 <xsl:copy-of select="my:getData($key,$id, $cache)"></xsl:copy-of> 167 195 </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> 170 205 <xsl:function name="my:getRawData"> 171 206 <xsl:param name="key"></xsl:param> … … 183 218 184 219 --> 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'])" /> 186 221 187 222 <xsl:message><xsl:value-of select="$key" />:</xsl:message> … … 194 229 </xsl:function> 195 230 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> 199 237 <xsl:template name="load-dcr"> 200 238 <Termsets type="dcr"> … … 202 240 <xsl:variable name="dcr_termset" select="document(url)" /> 203 241 <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="." /> 205 243 <xsl:with-param name="set" select="key"></xsl:with-param> 206 244 </xsl:apply-templates> 207 </xsl:for-each> 245 </xsl:for-each> 208 246 </Termsets> 209 247 </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 216 319 <xsl:template name="load-profiles"> 217 320 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>-\-> 219 322 <xsl:variable name="profiles" select="my:getData('cmd-profiles-raw')"></xsl:variable> 220 323 221 <!-- ??? <xsl:apply-templates select="$profiles" mode="include" />-->324 <!-\- ??? <xsl:apply-templates select="$profiles" mode="include" />-\-> 222 325 223 326 <xsl:for-each select="$profiles//profileDescription[id]"> … … 228 331 </xsl:call-template> 229 332 </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> 230 356 231 357 </xsl:template> … … 237 363 </xd:doc> 238 364 <xsl:template name="dcr-cmd-map"> 365 <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" /> 239 366 <Termset type="dcr-cmd-map" > 240 367 <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat"> -
SMC/trunk/SMC/src/xsl/smc_init.xsl
r3440 r3468 62 62 <xsl:call-template name="load-profiles"></xsl:call-template> 63 63 </xsl:when> 64 <xsl:when test="$data_key = 'dcr-terms'"> 65 <xsl:call-template name="postload-datcats" /> 66 </xsl:when> 64 67 <xsl:otherwise> 65 68 <xsl:call-template name="getData">
Note: See TracChangeset
for help on using the changeset viewer.