Changeset 6835


Ignore:
Timestamp:
11/23/15 10:49:56 (8 years ago)
Author:
matej.durco@oeaw.ac.at
Message:

smaller corrections/updates to xsl-code

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

Legend:

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

    r3472 r6835  
    4141 -->
    4242 
    43  <!--  handling compressed dcif-format
    44         <dcif:dataCategory definition="start time of recording" identifier="recordingTime"
    45         name="recording time" owner="Reichel, Uwe" pid="http://www.isocat.org/datcat/DC-4521"
    46         type="complex" version="1:0">
    47         <dcif:conceptualDomain type="constrained">
    48         <dcif:dataType>string</dcif:dataType>
    49         <dcif:ruleType>XML Schema regular expression</dcif:ruleType>
    50         <dcif:rule>([01][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]</dcif:rule>
    51         </dcif:conceptualDomain>
    52         </dcif:dataCategory>   
    53  -->
     43
     44        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     45                <xd:desc>
     46                        <xd:p>handling compressed dcif-format</xd:p>
     47                        <xd:pre>
     48                                        <dcif:dataCategory definition="start time of recording" identifier="recordingTime"
     49                                        name="recording time" owner="Reichel, Uwe" pid="http://www.isocat.org/datcat/DC-4521"
     50                                        type="complex" version="1:0">
     51                                        <dcif:conceptualDomain type="constrained">
     52                                        <dcif:dataType>string</dcif:dataType>
     53                                        <dcif:ruleType>XML Schema regular expression</dcif:ruleType>
     54                                        <dcif:rule>([01][0-9]|2[0-4]):[0-5][0-9]:[0-5][0-9]</dcif:rule>
     55                                        </dcif:conceptualDomain>
     56                                        </dcif:dataCategory>   
     57                        </xd:pre>
     58                </xd:desc>
     59               
     60                <xd:param name="set">the set from which the concept is coming (only valid value: 'isocat' (?))</xd:param>
     61        </xd:doc>
    5462<xsl:template match="dcif:dataCategory[@name]" >
    5563        <xsl:param name="set" />
     
    7684</xsl:template>
    7785
    78  <!--  handling full dcif-format -->
     86        <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     87                <xd:desc>
     88                        <xd:p>handling full dcif-format </xd:p>
     89                        <xd:p>TODO: should process all ocurring languages</xd:p>
     90                </xd:desc>
     91                <xd:param name="set"></xd:param>
     92        </xd:doc>
    7993<xsl:template match="dcif:dataCategory" >
    8094        <xsl:param name="set" />
     
    104118        <Concept type="datcat" id="{@pid}" datcat-type="{@type}">
    105119                <Term set="{$set}" type="mnemonic" >                     
     120                        <xsl:value-of select=".//dcif:identifier" />                   
     121                </Term>
     122                <Term set="{$set}" type="mnemonic" xml:lang="{($n/*/xs:string(@xml:lang),$lang)[1]}" >                   
    106123                        <xsl:value-of select="$n" />
    107124                </Term>
  • SMC/trunk/SMC/src/xsl/graph2json-d3.xsl

    r3435 r6835  
    9898        <xsl:text>, "value":</xsl:text>
    9999        <xsl:value-of select="@value"/>
     100        <xsl:if test="exists(@weight)" >
     101           <xsl:text>, "weight":</xsl:text>
     102           <xsl:value-of select="@weight"/>
     103        </xsl:if>
    100104<!--        <xsl:text>{"source":"</xsl:text><xsl:value-of select="@from" /><xsl:text>", "target":"</xsl:text><xsl:value-of select="@to" /><xsl:text>", "value":</xsl:text><xsl:value-of select="$count" />-->
    101105        <xsl:text>}</xsl:text>
  • SMC/trunk/SMC/src/xsl/smc2stats_datasets.xsl

    r3481 r6835  
    2424 
    2525
    26 <xsl:import href="smc_commons.xsl"/>
     26<xsl:import href="smc_commons_vars.xsl"/>
    2727
    2828        <xsl:output method="xml" indent="yes" />
     
    3030  <xsl:param name="title" select="'SMC Stats'" />
    3131
     32  <xsl:param name="parts" select="'overall,profiles,components,datcats,ambigue-terms,list'" />
     33       
    3234        <!--
    3335               
     
    7173        <xsl:template match="/">
    7274                <multiresult>
    73                 <xsl:call-template name="summary-overall"></xsl:call-template>
    74                         <xsl:call-template name="summary-profiles"></xsl:call-template>
    75                         <xsl:call-template name="summary-components"></xsl:call-template>
    76                         <xsl:call-template name="summary-datcats"></xsl:call-template>
    77                         <xsl:call-template name="ambigue-terms"></xsl:call-template>
     75                        <xsl:if test="contains($parts, 'overall')" ><xsl:call-template name="summary-overall"></xsl:call-template></xsl:if>
     76                        <xsl:if test="contains($parts, 'profiles')" ><xsl:call-template name="summary-profiles"></xsl:call-template></xsl:if>
     77                        <xsl:if test="contains($parts, 'components')" ><xsl:call-template name="summary-components"></xsl:call-template></xsl:if>
     78                        <xsl:if test="contains($parts, 'datcats')" ><xsl:call-template name="summary-datcats"></xsl:call-template></xsl:if>
     79                        <xsl:if test="contains($parts, 'ambigue-terms')" ><xsl:call-template name="ambigue-terms"></xsl:call-template></xsl:if>
    7880                </multiresult>
    7981<!--            <xsl:call-template name="summary-concepts"></xsl:call-template>
     
    99101                        <ds:label key="elems-without-datcats">Elements without DatCats</ds:label>
    100102                        <ds:label key="elems-without-datcats-ratio" >ratio of elements without DatCats</ds:label>                       
    101 <!--                    <ds:label key="distinct-datcats">distinct used Data Categories</ds:label>-->                   
     103                        <ds:label key="distinct-datcats">distinct used Data Categories</ds:label>                       
    102104                        <ds:label key="used-concepts">used Concept</ds:label>
    103105                        <ds:label key="available-concepts">available Concepts (in Metadata profile or used in CMD)</ds:label>
     
    120122                        <ds:value key="elems-without-datcats-ratio" formatted="{format-number($elems-distinct-without-datcats-ratio, '0.00 %')}">
    121123                                <xsl:value-of select="$elems-distinct-without-datcats-ratio"/></ds:value>
    122 <!--                    <ds:value key="distinct-datcats"><xsl:value-of select="$count_distinct_datcats"/></ds:value>-->
     124                        <ds:value key="distinct-datcats"><xsl:value-of select="$count_distinct_datcats"/></ds:value>
    123125                        <ds:value key="used-concepts"><xsl:value-of select="count($dcr-cmd-map//Concept)"/></ds:value>
    124126<!--                    <ds:value key="blind-concepts"><xsl:value-of select="count(//Concept[not(Term[@set='isocat'])])"/></ds:value>-->
     
    213215                                <xsl:with-param name="key">distinct-datcats</xsl:with-param>
    214216                                <xsl:with-param name="type">datcat</xsl:with-param>
    215                                 <xsl:with-param name="data" select="distinct-values(./Term[@type='CMD_Element']/@datcat[not(.='')])"></xsl:with-param>
     217<!--                            <xsl:with-param name="data" select="distinct-values(./Term[@type='CMD_Element']/@datcat[not(.='')])"></xsl:with-param>-->
     218                                <xsl:with-param name="data" select="distinct-values(./Term/data(@datcat[not(.='')]))"></xsl:with-param>
    216219                        </xsl:call-template>
    217220                       
    218 <!--                    <ds:value key=""><xsl:value-of select="$count_distinct_datcats"/></ds:value>-->
     221<!--                    <ds:value key=""><xsl:value-of select="$count_distinct_datcats"/></ds:value>-->                 
    219222                        <ds:value key="elems-with-datcats"><xsl:value-of select="count(./Term[@type='CMD_Element']/@datcat[not(.='')])"/></ds:value>
    220223                        <ds:value key="elems-without-datcats"><xsl:value-of select="count(./Term[@type='CMD_Element'][@datcat=''])"/></ds:value>
     224<!--                    <ds:value key="comp-with-datcats"><xsl:value-of select="count(./Term[@type='CMD_Components']/@datcat[not(.='')])"/></ds:value>-->
    221225                        <xsl:variable name="elems-without-datcats-ratio" select="if($count_elems &gt; 0) then count(./Term[@type='CMD_Element'][@datcat='']) div $count_elems else 0"></xsl:variable>
    222226                        <ds:value key="elems-without-datcats-ratio" formatted="{format-number($elems-without-datcats-ratio, '0.00 %')}">
     
    283287                        id="#applicationType">AnnotationTool.applicationType</Term>-->
    284288                <xsl:for-each select="$dcr-cmd-map//Concept" >                   
    285                         <xsl:sort select="lower-case(Term[@type='label'][1])" order="ascending"/>
     289<!--                    <xsl:sort select="lower-case(Term[@type=('label','mnemonic')][1])" order="ascending"/>-->
     290                        <xsl:sort select="count(distinct-values(Term[@type='full-path']/@schema))" data-type="number" order="descending"/>
     291                       
    286292                       
    287293                        <xsl:variable name="def" select="$dcr-terms//Concept[@id=current()/@id]/info[1]" ></xsl:variable>
     
    289295                        <xsl:variable name="profiles" select="distinct-values(Term[@type='full-path']/@schema)" ></xsl:variable>
    290296                       
    291                         <ds:dataseries key="{@id}" label="{Term[@type='label'][1]}" >
     297                        <ds:dataseries key="{@id}" label="{concat(Term[@type=('label','mnemonic')][1],' [', my:shortURL(@id), ']')}" >
    292298                                <!--                    <ds:value key="distinct-components"><xsl:value-of select="$count_distinct_components"/></ds:value>-->
    293299                               
    294                                 <ds:value key="def"><xsl:value-of select="$def"/></ds:value>
     300                                <ds:value key="def"><xsl:value-of select="$def"/></ds:value>                           
    295301                                <xsl:call-template name="list">
    296302                                        <xsl:with-param name="key" >used-in-profiles</xsl:with-param>
     
    423429<xsl:param name="type" ></xsl:param>
    424430<xsl:param name="data" ></xsl:param>
    425        
    426431        <xsl:variable name="processed_data">
    427432                <xsl:choose>
     
    474479        </xsl:variable>
    475480        <ds:value key="{$key}" abs="{count($processed_data/*)}" >
    476                 <ds:list>
    477                         <xsl:for-each select="$processed_data/*" >
    478                                 <xsl:sort select="lower-case(.)" ></xsl:sort>
    479                                 <!--<xsl:variable name="profile-name" select="$all_profiles[@id=current()]/@name"></xsl:variable>-->
    480 <!--                            <li><a href="#{.}" ><xsl:value-of select="$profile-name" /></a></li>-->
    481                                         <xsl:copy-of select="."></xsl:copy-of>
    482                         </xsl:for-each>
    483                 </ds:list>
     481                <xsl:if test="contains($parts,'list')" >
     482                       
     483                        <ds:list>
     484                                <xsl:for-each select="$processed_data/*" >
     485                                        <xsl:sort select="lower-case(.)" ></xsl:sort>
     486                                        <!--<xsl:variable name="profile-name" select="$all_profiles[@id=current()]/@name"></xsl:variable>-->
     487        <!--                            <li><a href="#{.}" ><xsl:value-of select="$profile-name" /></a></li>-->
     488                                                <xsl:copy-of select="."></xsl:copy-of>
     489                                </xsl:for-each>
     490                        </ds:list>
     491                </xsl:if>
    484492        </ds:value>
    485493</xsl:template>
  • SMC/trunk/SMC/src/xsl/smc_commons.xsl

    r5213 r6835  
    6969                    <xsl:with-param name="message">getData writing to: <xsl:value-of select="$cache_path"></xsl:value-of></xsl:with-param>                                                     
    7070                </xsl:call-template>
    71                
    72              <xsl:result-document href="{$cache_path}" format="xml" >
     71                 
     72             <xsl:result-document href="{$cache_path}" format="xml"  >
    7373                 <xsl:sequence select="$result" />
    7474             </xsl:result-document>
  • SMC/trunk/SMC/src/xsl/terms2graph.xsl

    r3527 r6835  
    2626    </xd:doc>
    2727
    28     <xsl:output method="xml" encoding="utf-8"/>
     28    <xsl:output method="xml" encoding="utf-8" indent="yes"/>
    2929
    3030    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     
    3434            <xd:p>recognized values: collections,components,profile-groups,datcats,relations (delimited by ',')</xd:p>           
    3535            <xd:p>if datcats and no components - direct links between profiles and datcats are generated</xd:p>
     36            <xd:p>if no datcats and no components - direct links between profiles are generated (weighted by the number of shared data categories</xd:p>
    3637            <xd:p>profile-groups generates extra nodes grouping profiles by metadata (creatore, groupName, domainName)</xd:p>
    3738        </xd:desc>
    3839    </xd:doc>
    3940<!--        <xsl:param name="parts" select="'profile-groups'"/>-->
     41    <xsl:param name="debug" select="false()"/>
    4042    <xsl:param name="parts" select="'collections,profile-groups,components,datcats,relations'"/>
    4143    <xsl:variable name="parts-sequence" select="tokenize($parts,',')"></xsl:variable>
     
    4749    </xd:doc>
    4850    <xsl:param name="profiles" select="''"/>  <!--teiHeader-->
     51   
     52    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     53        <xd:desc>
     54            <xd:p>threshold for the similarity quotient (matched_datcats : profile_terms), when linking profiles (mode=edges-profiles)</xd:p>
     55        </xd:desc>
     56    </xd:doc>
     57    <xsl:param name="match_threshold" select="0.5"/>
     58   
    4959
    5060
     
    110120    </xd:doc>
    111121    <xsl:key name="cmd-terms-path" match="Term" use="@path"/>
     122   
     123    <xsl:key name="cmd-terms-datcat" match="Term" use="@datcat"/>
    112124
    113125    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     
    207219            <xsl:if test="'datcats' = $parts-sequence and 'components' = $parts-sequence" ><xsl:apply-templates select="$enriched-termsets//Term" mode="edges-datcats"/></xsl:if>
    208220            <xsl:if test="'datcats' = $parts-sequence and not('components' = $parts-sequence)" ><xsl:apply-templates select="$enriched-termsets//Term" mode="edges-profiles-datcats"/></xsl:if>
     221            <xsl:if test="not('datcats' = $parts-sequence) and not('components' = $parts-sequence)" ><xsl:apply-templates select="$enriched-termsets//Termset[@type='CMD_Profile']" mode="edges-profiles"/></xsl:if>
    209222            <xsl:if test="'relations' = $parts-sequence" ><xsl:apply-templates select="$rr-relations//Relation" mode="edges-rels"/></xsl:if>           
    210223            <xsl:if test="'profile-groups' = $parts-sequence">
     
    221234        <xsl:variable name="distinct-edges">
    222235            <xsl:for-each-group select="$edges/*" group-by="concat(@from, @to)">
    223                 <xsl:variable name="count" select="count(current-group())"/>
     236                <xsl:variable name="value" select="if (exists(@value)) then sum(@value) else count(current-group())"/>
     237                <xsl:variable name="weight" select="if (exists(@weight)) then sum(@weight) else 1"/>
    224238                <xsl:variable name="ix_from" select="$distinct-nodes/*[@key=current()/@from]/@position - 1 "/>
    225239                <xsl:variable name="ix_to" select="$distinct-nodes/*[@key=current()/@to]/@position - 1"/>
    226                 <edge ix_from="{$ix_from}" ix_to="{$ix_to}" from="{@from}" to="{@to}" value="{$count}"/>
     240                <edge ix_from="{$ix_from}" ix_to="{$ix_to}" from="{@from}" to="{@to}" value="{$value}" weight="{$weight}"/>
    227241            </xsl:for-each-group>
    228242        </xsl:variable>
    229243        <xsl:variable name="graph">
    230244            <graph>
    231                 <nodes count="{count($filtered-termsets//Term)}">
     245<!--                <nodes count="{count($filtered-termsets//Term)}">-->
     246           <nodes count="{count($distinct-nodes)}">
    232247                   
    233248<!--                                                            <xsl:copy-of select="$dcr-terms-copy"/>-->
     
    237252                <edges>
    238253                    <xsl:copy-of select="$distinct-edges"/>
    239 <!--                    <debug><xsl:copy-of select="$edges"/></debug>-->
     254                    <xsl:if test="$debug"><debug><xsl:copy-of select="$edges"/></debug></xsl:if>
    240255                </edges>
    241256            </graph>
     
    256271       
    257272        <xsl:variable name="current_profile_key" select="my:normalize(@id)"/>
    258         <node id="{@id}" key="{$current_profile_key}" name="{@name}" type="Profile" level="0" count="{@count}" path="{@path}">
     273        <node id="{@id}" key="{$current_profile_key}" name="{@name}" type="Profile" level="0" count="{(@count, count(.//Term))[1]}" path="{@path}">
    259274            <!--       <xsl:value-of select="$equivalent_schema_term"></xsl:value-of>-->
    260275        </node>
     
    262277        <xsl:if test="xs:string(@id) ne Term/xs:string(@id)">
    263278            <xsl:for-each select="Term">
    264                 <node id="{@id}" key="{my:normalize(@id)}" name="{@name}" type="Component" level="1" count="{@count}" path="{@path}"/>
     279                <node id="{@id}" key="{my:normalize(@id)}" name="{@name}" type="Component" level="1" count="{(@count, count(.//Term))[1]}" path="{@path}"/>
    265280            </xsl:for-each>
    266281        </xsl:if>
     
    470485        <xsl:variable name="current_profile_key" select="my:normalize(ancestor::Termset/@id)"/>
    471486        <edge from="{$current_profile_key}" to="{my:normalize(@datcat)}"/>
     487    </xsl:template>
     488
     489    <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl">
     490        <xd:desc>
     491            <xd:p>create direct links between profiles based on shared Datcats</xd:p>
     492        </xd:desc>
     493    </xd:doc>
     494    <xsl:template match="Termset[@type='CMD_Profile']" mode="edges-profiles">
     495        <xsl:variable name="current_profile_key" select="my:normalize(@id)"/>
     496        <xsl:variable name="current_profile_name" select="@name"/>
     497        <xsl:variable name="profile_datcats" select="distinct-values(.//Term/data(@datcat)[not(.='')])"/>
     498        <xsl:variable name="profile_terms" select=".//Term/data(@id)"/>
     499<!--        <edge from="{$current_profile_key}" weight="{count($profile_datcats)}"/>-->
     500        <xsl:for-each select="following-sibling::Termset" >
     501            <xsl:variable name="other_profile_key" select="my:normalize(@id)"/>
     502            <xsl:variable name="matching_datcats" select="distinct-values(.//Term[not(@datcat='')][@datcat=$profile_datcats]/data(@datcat))"/>
     503            <xsl:variable name="other_datcats" select="distinct-values(.//Term[not(@datcat='')]/data(@datcat))"/>
     504            <xsl:variable name="matching_terms" select="distinct-values(.//Term[@id=$profile_terms]/data(@id))"/>
     505            <!--<xsl:variable name="matching_datcats">           
     506                <xsl:copy-of select=".//Term[key('cmd-terms-datcat',$profile_datcats)]"/>           
     507            </xsl:variable>-->
     508<!--            <xsl:if test="exists($matching_datcats)" > -->
     509            <xsl:variable name="match_quotient1" select="if (exists($profile_datcats)) then count($matching_datcats) div count($profile_datcats) else 0 " />
     510            <xsl:variable name="match_quotient2" select="if (exists($other_datcats)) then count($matching_datcats) div count($other_datcats) else 0" />
     511            <xsl:variable name="match_quotient" select="number(($match_quotient1 + $match_quotient2) div 2)" />
     512           
     513            <xsl:if test="number($match_quotient) &gt; number($match_threshold)" >
     514            <!--<xsl:if test="not(number($match_quotient) = number($match_quotient))" > 
     515            <xsl:message>DEBUG: <xsl:value-of select="$match_quotient"></xsl:value-of> </xsl:message>
     516            </xsl:if>-->
     517<!--                weight="{count($matching_datcats) + count($matching_terms)}"-->
     518                <edge from="{$current_profile_key}" to="{$other_profile_key}"
     519                    from_name="{$current_profile_name}" to_name="{data(@name)}"
     520                    value="{count($matching_datcats)}"
     521                    weight="{$match_quotient}"                   
     522                    count_matching_distinct_terms="{count($matching_terms)}" match_quotient="{$match_quotient}"
     523                    count_matching_datcats="{count($matching_datcats)}"
     524                    count_profile_datcats="{count($profile_datcats)}"
     525                    count_other_datcats="{count($other_datcats)}"
     526                    count_terms="{count($profile_terms)}"
     527                    count_other_terms="{count(.//Term)}"
     528                    >
     529                   <!--DEBUG:
     530                       <xsl:copy-of select="$matching_datcats"></xsl:copy-of>-->
     531               </edge>
     532            </xsl:if>
     533           
     534        </xsl:for-each>
     535       
    472536    </xsl:template>
    473537   
Note: See TracChangeset for help on using the changeset viewer.