Changeset 2235 for SMC


Ignore:
Timestamp:
09/19/12 10:36:16 (12 years ago)
Author:
vronk
Message:

intermediate commit of older minor(?) changes

Location:
SMC/trunk/SMC/src/scripts
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • SMC/trunk/SMC/src/scripts/cmd_includes.xsl

    r1657 r2235  
    5555        <!--  <xsl:variable name="resolved_uri" select="concat($root_uri, '/', id)" />-->
    5656        <!--<xsl:variable name="resolved_uri" select="concat($cmd_profiles_uri , '/', my:extractID(id))" />-->
    57         <xsl:variable name="resolved_uri" select="concat($cmd_profiles_uri , id)" />
     57        <xsl:variable name="resolved_uri" select="concat($cmd_profiles_uri , id, '/xml')" />
    5858       
    5959        <xsl:message>PROFILE: document-uri:<xsl:value-of select="document-uri(/)" /></xsl:message>
  • SMC/trunk/SMC/src/scripts/dcr_rdf2terms.xsl

    r1607 r2235  
    66  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    77  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
     8  xmlns:dcif="http://www.isocat.org/ns/dcif"
    89  exclude-result-prefixes="dcr rdf rdfs"
    910>
     
    2425<xsl:output method="xml" indent="yes" > </xsl:output>
    2526
    26         <xsl:param name="isocat_prefix" select="'http://www.isocat.org/datcat/'"></xsl:param>
     27<!--    <xsl:param name="isocat_prefix" select="'http://www.isocat.org/datcat/'"></xsl:param>-->
    2728
    2829 <!--
    2930        decide based on the inner-structure, what it is and how to handle
    3031        -->
    31 <xsl:template match="*" mode="dcr">
     32<xsl:template match="*" mode="dcr">     
     33        <xsl:param name="config-node" />
    3234        <xsl:param name="set" />
    3335       
    34         <Termset set="{$set}">
    35                 <xsl:apply-templates select="/rdf:RDF/rdf:Description | /rdf:RDF/rdf:Property ">
     36        <Termset set="{$set}" name="{$config-node/name}" url="{$config-node/url_prefix}" >
     37                <xsl:apply-templates select="/rdf:RDF/rdf:Description | /rdf:RDF/rdf:Property | /dcif:dataCategorySelection/dcif:dataCategory  ">
    3638                        <xsl:with-param name="set" select="$set" />
    3739                </xsl:apply-templates>
    3840        </Termset>
    3941</xsl:template>
     42
     43<xsl:template match="*" mode="rr">
     44        <xsl:param name="set" />
     45       
     46        <Termset set="{$set}">
     47                <xsl:apply-templates select="/rdf:RDF/rdf:Description" mode="rr">
     48                        <xsl:with-param name="set" select="$set" />
     49                </xsl:apply-templates>
     50        </Termset>
     51</xsl:template>
     52
    4053
    4154        <!-- isocat.rdf -->
     
    8093        </Concept>
    8194</xsl:template>
    82        
     95
     96<!-- process relations from RR -->
     97        <xsl:template match="rdf:Description" mode="rr">
     98                <xsl:param name="set" />               
     99                <xsl:variable name="reltype" select= "*/name()" />
     100                <Relation type="{$reltype}" >
     101                        <Concept type="datcat" id="{@rdf:about}" role="about"></Concept>                       
     102                        <Concept type="datcat" id="{*/@rdf:resource}" ></Concept>
     103                </Relation>
     104        </xsl:template>
    83105</xsl:stylesheet>
  • SMC/trunk/SMC/src/scripts/dcr_smc2skos.xsl

    r2225 r2235  
    1313        exclude-result-prefixes="xs my"
    1414        >
     15<xsl:import href="smc_commons.xsl"/>
     16       
    1517        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" scope="stylesheet">
    1618                <xd:desc>
     
    2325        </xd:doc>
    2426
    25 <xsl:import href="smc_commons.xsl"/>
     27
    2628
    2729        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
  • SMC/trunk/SMC/src/scripts/smc_commons.xsl

    r1876 r2235  
    77    <xsl:include href="cmd_includes.xsl"/>   
    88    <xsl:include href="dcr_rdf2terms.xsl"/>
     9    <xsl:include href="dcr_dcif2terms.xsl"/>
    910   
    1011    <!-- use either input (precedence) or the config-file as the termsets configuration -->
     
    2627<!-- intermediate datasets bound into variables,to prevent calling the function every time -->
    2728   <xsl:variable name="dcr-terms" select="my:getData('dcr-terms')" />
     29    <xsl:variable name="rr-relations" select="my:getData('rr-relations')" />
     30    <!-- rr-relations expanded with terms-->
     31    <xsl:variable name="rr-terms" select="my:getData('rr-terms')" />
    2832   <xsl:variable name="cmd-terms" select="my:getData('cmd-terms')" />
     33    <xsl:variable name="cmd-terms-nested" select="my:getData('cmd-terms-nested')" />
    2934   <xsl:variable name="dcr-cmd-map" select="my:getData('dcr-cmd-map')" />
    3035   <xsl:variable name="isocat-languages" select="my:getData('isocat-languages')" />
     
    4146        <xsl:variable name="cached_data_file" select="concat($cache_dir, $key, '.xml')"></xsl:variable>
    4247        <xsl:message>
    43             cache: <xsl:value-of select="$cache" />
     48            cache: <xsl:value-of select="$cache" /> -
    4449            <xsl:value-of select="$cached_data_file" />: <xsl:value-of select="doc-available($cached_data_file)" />
    4550        </xsl:message>
     
    4853                <xsl:message>reading in: <xsl:value-of select="$cached_data_file" />                   
    4954                </xsl:message>
    50                 <xsl:copy-of select="document($cached_data_file)"></xsl:copy-of>
     55                <xsl:copy-of select="doc($cached_data_file)"></xsl:copy-of>
    5156            </xsl:when>
    5257            <xsl:when test="$key='cmd-profiles-raw'">
     
    5762            </xsl:when>
    5863            <xsl:when test="$key='cmd-terms'">
    59                 <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription)" />
    60             </xsl:when>
     64                <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription,false())" />
     65            </xsl:when>
     66            <xsl:when test="$key='cmd-terms-nested'">
     67                <xsl:copy-of select="my:profiles2termsets(my:getData('cmd-resolved')//profileDescription,true())" />
     68            </xsl:when>
     69            <xsl:when test="$key='cmd-terms-nested-minimal'">
     70                <xsl:apply-templates select="$cmd-terms-nested" mode="min-context"></xsl:apply-templates>
     71            </xsl:when>           
    6172            <xsl:when test="$key='dcr-terms'">
    6273                <xsl:call-template name="load-dcr" />                                                           
    6374            </xsl:when>
     75            <xsl:when test="$key='rr-relations'">
     76                <xsl:call-template name="load-rr-relations" />                                                         
     77            </xsl:when>
     78            <xsl:when test="$key='rr-terms'">
     79                <xsl:call-template name="rr-terms" />                                                           
     80            </xsl:when>           
    6481            <xsl:when test="$key='termsets'">
    6582                <xsl:call-template name="termsets" />                                                           
     
    94111              <xsl:variable name="dcr_termset" select="document(url)" />           
    95112                  <xsl:apply-templates select="$dcr_termset" mode="dcr" >
     113                      <xsl:with-param name="config-node" select="."></xsl:with-param>
    96114                      <xsl:with-param name="set" select="key"></xsl:with-param>
    97115                  </xsl:apply-templates>             
     
    100118    </xsl:template>
    101119
     120       
    102121<!-- invert the profiles-termsets + match with data from DCRs = create map datcat -> cmd-elements[] -->
    103122<xsl:template name="dcr-cmd-map">
     
    105124        <xsl:for-each-group select="$cmd-terms//Term[not(@datcat='')]" group-by="@datcat">
    106125            <Concept id="{@datcat}" type="datcat">
    107                 <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" />               
     126                <xsl:copy-of select="$dcr-terms//Concept[@id=current()/@datcat]/Term" exclude-result-prefixes="my" />               
    108127                <xsl:for-each select="current-group()">
    109128                    <xsl:variable name="parent_profile" select="ancestor::Termset[@type='CMD_Profile']/@id" />
     
    154173</xsl:template>
    155174
     175<!-- load relation sets from the configuration and transform into Termset/Relation/Concepet
     176        (uses mode=rr-templates in dcr_rdf2terms.xsl)       -->
     177    <xsl:template name="load-rr-relations">
     178        <Termsets type="rr">
     179            <xsl:for-each select="$termsets_config//*[type='rr']" >
     180                <xsl:variable name="rr_termset" select="document(url)" />           
     181                <xsl:apply-templates select="$rr_termset" mode="rr" >
     182                    <xsl:with-param name="set" select="key"></xsl:with-param>
     183                </xsl:apply-templates>             
     184            </xsl:for-each>
     185        </Termsets>
     186    </xsl:template>
     187
     188<!-- take the rr-relations and expand them with data from dcr-cmd-terms,
     189    to get rr-expanded terms      -->
     190    <xsl:template name="rr-terms">       
     191            <xsl:apply-templates select="$rr-relations" mode="rr-expand" ></xsl:apply-templates>             
     192    </xsl:template>
     193   
     194    <xsl:template match="*" mode="rr-expand">
     195        <xsl:copy>
     196            <xsl:copy-of select="@*" />
     197            <xsl:apply-templates mode="rr-expand"></xsl:apply-templates>
     198        </xsl:copy>
     199    </xsl:template>
     200    <!-- expand rr-concepts-->
     201    <xsl:template match="Concept" mode="rr-expand">
     202        <xsl:variable name="concept-id" select="@id" />               
     203        <xsl:copy>
     204            <xsl:copy-of select="@*" />           
     205            <xsl:copy-of select="$dcr-cmd-map//Concept[@id=$concept-id]/Term" />           
     206        </xsl:copy>       
     207    </xsl:template>
     208   
    156209<!-- return a property of a Termset from the configuration. -->   
    157210    <xsl:function name="my:config">
     
    160213        <xsl:value-of select="$termsets_config//*[key=$key]/*[name()=$property]"></xsl:value-of>
    161214    </xsl:function>
     215   
     216   
    162217</xsl:stylesheet>
  • SMC/trunk/SMC/src/scripts/smc_op.xsl

    r1683 r2235  
    1515 <xsl:param name="context">*</xsl:param>
    1616 <xsl:param name="term"></xsl:param>
     17 <xsl:param name="relset"></xsl:param>
    1718 <!--<xsl:param name="lang">pt</xsl:param>-->
    1819   
     
    2223                <xsl:when test="$operation='map'">
    2324                    <Terms>
    24                  <xsl:variable name="matching_concepts" select="$dcr-cmd-map//Concept[Term=$term]"></xsl:variable>
     25                 <xsl:variable name="matching_concepts" >
     26                     <xsl:choose>
     27                         <xsl:when test="$relset=''">
     28                             <xsl:copy-of select="$dcr-cmd-map//Concept[Term/lower-case(text())=lower-case($term)]" />
     29                         </xsl:when>
     30                         <xsl:otherwise>
     31                             <xsl:variable name="matching-concept" select="$dcr-cmd-map//Concept[Term/lower-case(text())=lower-case($term)]" />
     32                             <!-- this returns both, the original concept and the expanded/related one -->
     33                             <xsl:variable name="related-concepts" select="$rr-relations//Termset[@set='rr-cmdi']//Concept[@id=$matching-concept/@id]/parent::Relation/Concept" />
     34                             <xsl:copy-of select="$dcr-cmd-map//Concept[@id = $related-concepts/@id]" />
     35                         </xsl:otherwise>
     36                     </xsl:choose>
     37                     
     38                 </xsl:variable>
    2539                     <xsl:for-each select="$matching_concepts//Term[@set='cmd']">
    2640                         <xsl:copy-of select="." />                 
Note: See TracChangeset for help on using the changeset viewer.