Changeset 3469
- Timestamp:
- 08/24/13 12:32:17 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SMC/trunk/SMC/src/xsl/terms2graph.xsl
r3462 r3469 21 21 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 22 22 <xd:desc> 23 <xd:p>allows to restrict the outputted graph-nodes and edges by type </xd:p> 24 <xd:p>profiles are output always</xd:p> 25 <xd:p>recognized values: collections,components,profile-groups,datcats,relations (delimited by ',')</xd:p> 26 <xd:p>if datcats and no components - direct links between profiles and datcats are generated</xd:p> 27 <xd:p>profile-groups generates extra nodes grouping profiles by metadata (creatore, groupName, domainName)</xd:p> 28 </xd:desc> 29 </xd:doc> 30 <!-- <xsl:param name="parts" select="'profile-groups'"/>--> 31 <xsl:param name="parts" select="'collections,profile-groups,components,datcats,relations'"/> 32 <xsl:variable name="parts-sequence" select="tokenize($parts,',')"></xsl:variable> 33 34 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 35 <xd:desc> 23 36 <xd:p></xd:p> 24 37 </xd:desc> 25 38 </xd:doc> 26 39 <xsl:param name="profiles" select="''"/> <!--teiHeader--> 27 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 28 <xd:desc> 29 <xd:p></xd:p> 30 </xd:desc> 31 </xd:doc> 32 <xsl:param name="format" select="'xml'"/> <!-- xml | json-d3 ; todo: dot, json-jit? --> 40 41 33 42 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 34 43 <xd:desc> … … 156 165 <!-\- DEBUG:-<xsl:value-of select="current()/@name"/><xsl:copy-of select="$profile"></xsl:copy-of>-\-> 157 166 --> 158 <xsl: apply-templates select="$enriched-termsets//Termset[@context]" mode="nodes-collections"/>167 <xsl:if test="'collections' = $parts-sequence"><xsl:apply-templates select="$enriched-termsets//Termset[@context]" mode="nodes-collections"/></xsl:if> 159 168 <xsl:apply-templates select="$enriched-termsets//Termset[@type='CMD_Profile']" mode="nodes"/> 160 <xsl:apply-templates select="$enriched-termsets//Term" mode="nodes"> 161 <!-- <xsl:with-param name="cmd-terms" select="$profile"></xsl:with-param>--> 162 </xsl:apply-templates> 163 <xsl:apply-templates select="$enriched-termsets//Term" mode="nodes-datcats"/> 164 <xsl:for-each-group select="$rr-relations//Concept" group-by="@id"> 165 <xsl:variable name="datcat-id" select="@id"/> 166 <xsl:variable name="get-mnemonic"> 167 <xsl:for-each select="$dcr-terms-copy"> 168 <xsl:copy-of select="key('dcr-terms', $datcat-id)/Term[@type=('mnemonic','label')][1]"/> 169 <!-- /Concept/Term[@type='mnemonic']--> 170 </xsl:for-each> 171 </xsl:variable> 172 <xsl:variable name="datcat-name"> 173 <!-- <xsl:variable name="get-mnemonic" select="$dcr-terms//Concept[@id=current()/@datcat]/Term[@type='mnemonic']"/>--> 174 <xsl:value-of select="if($get-mnemonic ne '') then $get-mnemonic else tokenize($datcat-id,'/')[last()]"/> 175 </xsl:variable> 176 <node id="{@id}" key="{my:normalize(@id)}" name="{$datcat-name}" type="DatCat"> 177 <xsl:copy-of select="@*[not (name()=('count','type'))]"/> 178 </node> 179 </xsl:for-each-group> 169 <xsl:if test="'profile-groups' = $parts-sequence"> 170 <xsl:call-template name="nodes-profile-groups"><xsl:with-param name="termsets" select="$enriched-termsets" /></xsl:call-template> 171 </xsl:if> 172 <xsl:if test="'components' = $parts-sequence"><xsl:apply-templates select="$enriched-termsets//Term" mode="nodes" /></xsl:if> 173 <xsl:if test="'datcats' = $parts-sequence"><xsl:apply-templates select="$enriched-termsets//Term" mode="nodes-datcats"/></xsl:if> 174 <xsl:if test="'relations' = $parts-sequence"> 175 <xsl:for-each-group select="$rr-relations//Concept" group-by="@id"> 176 <xsl:variable name="datcat-id" select="@id"/> 177 <xsl:variable name="get-mnemonic"> 178 <xsl:for-each select="$dcr-terms-copy"> 179 <xsl:copy-of select="key('dcr-terms', $datcat-id)/Term[@type=('mnemonic','label')][1]"/> 180 <!-- /Concept/Term[@type='mnemonic']--> 181 </xsl:for-each> 182 </xsl:variable> 183 <xsl:variable name="datcat-name"> 184 <!-- <xsl:variable name="get-mnemonic" select="$dcr-terms//Concept[@id=current()/@datcat]/Term[@type='mnemonic']"/>--> 185 <xsl:value-of select="if($get-mnemonic ne '') then $get-mnemonic else tokenize($datcat-id,'/')[last()]"/> 186 </xsl:variable> 187 <node id="{@id}" key="{my:normalize(@id)}" name="{$datcat-name}" type="DatCat"> 188 <xsl:copy-of select="@*[not (name()=('count','type'))]"/> 189 </node> 190 </xsl:for-each-group> 191 </xsl:if> 180 192 181 193 <!-- </xsl:for-each>--> 182 194 </xsl:variable> 183 195 <xsl:variable name="edges"> 184 <xsl:apply-templates select="$enriched-termsets//Termset[@context]/Term" mode="edges-collections"/> 185 <xsl:apply-templates select="$enriched-termsets//Term" mode="edges"/> 186 <xsl:apply-templates select="$enriched-termsets//Term" mode="edges-datcats"/> 187 <!-- <xsl:apply-templates select="$enriched-termsets//Term" mode="edges-profiles-datcats"/>--> 188 <!-- <xsl:apply-templates select="$rr-relations//Relation" mode="edges-rels"/>--> 196 <xsl:if test="'collections' = $parts-sequence"><xsl:apply-templates select="$enriched-termsets//Termset[@context]/Term" mode="edges-collections"/></xsl:if> 197 <xsl:if test="'components' = $parts-sequence"><xsl:apply-templates select="$enriched-termsets//Term" mode="edges"/></xsl:if> 198 <xsl:if test="'datcats' = $parts-sequence and 'components' = $parts-sequence" ><xsl:apply-templates select="$enriched-termsets//Term" mode="edges-datcats"/></xsl:if> 199 <xsl:if test="'datcats' = $parts-sequence and not('components' = $parts-sequence)" ><xsl:apply-templates select="$enriched-termsets//Term" mode="edges-profiles-datcats"/></xsl:if> 200 <xsl:if test="'relation' = $parts-sequence" ><xsl:apply-templates select="$rr-relations//Relation" mode="edges-rels"/></xsl:if> 201 <xsl:if test="'profile-groups' = $parts-sequence"> 202 <xsl:apply-templates select="$enriched-termsets//info/(groupName | domainName | creatorName)[. ne '']" mode="edges-profiles-groups"/> 203 </xsl:if> 189 204 </xsl:variable> 190 205 <xsl:variable name="distinct-nodes"> … … 356 371 </xsl:template> 357 372 373 <xsl:template name="nodes-profile-groups"> 374 <xsl:param name="termsets"></xsl:param> 375 <xsl:for-each-group select="$termsets//Termset/info/(groupName | domainName | creatorName)[. ne '']" group-by="."> 376 <xsl:variable name="type" select="concat('profile-', substring-before(name(),'Name'))"/> 377 <xsl:variable name="node_key" select="my:normalize(concat($type, '_', .))"/> 378 <xsl:variable name="level" select="-1"/> 379 <xsl:variable name="count" select="count($termsets//Termset[info/*[local-name()=local-name(current())][. = current-grouping-key()]])"/> 380 381 <node id="{$node_key}" key="{$node_key}" name="{.}" type="{$type}" level="{$level}" count="{$count}" path="{$node_key}"/> 382 </xsl:for-each-group> 383 384 </xsl:template> 385 358 386 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 359 387 <xd:desc> … … 426 454 <edge from="{$current_profile_key}" to="{my:normalize(@datcat)}"/> 427 455 </xsl:template> 428 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 456 457 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 458 <xd:desc> 459 <xd:p>Generate links between the profiles and their respective profile-groups</xd:p> 460 <xd:pre>profile-group -> profile</xd:pre> 461 </xd:desc> 462 </xd:doc> 463 <xsl:template match="info/*" mode="edges-profiles-groups"> 429 464 430 </xd:doc> 465 <xsl:variable name="type" select="concat('profile-', substring-before(name(),'Name'))"/> 466 <xsl:variable name="node_key" select="my:normalize(concat($type, '_', .))"/> 467 468 <xsl:variable name="curr_profile_key" select="ancestor::Termset[@type='CMD_Profile']/my:normalize(@id)"/> 469 <edge from="{$node_key}" to="{$curr_profile_key}"/> 470 </xsl:template> 471 472 431 473 <xd:doc xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"> 432 474 <xd:desc>
Note: See TracChangeset
for help on using the changeset viewer.