sysmodellibs/sysmodelgen/src/old/svg/output-csv.xsl
changeset 6 5b32dc297d05
parent 1 b538b70cbe51
equal deleted inserted replaced
3:e7e0ae78773e 6:5b32dc297d05
       
     1 <stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform" 
       
     2 	exclude-result-prefixes="set exslt"
       
     3 	xmlns:exslt="http://exslt.org/common"
       
     4 	xmlns:set="http://exslt.org/sets">
       
     5 	<output method="text"/>
       
     6 	<!-- 
       
     7 	tech_domain,layer,block,collection,component,old_layer,old_package<value-of select="$atts"/>
       
     8 	Foundation Tech Domain,Foundation layer,Foundation package,Foundation collection,Component,Layer,Domain,Subsystem<value-of select="$atts"/>
       
     9 	-->
       
    10 	<variable name="default-atts">module,layer,block,subblock,collection,component</variable>
       
    11 	<param name="atts">
       
    12 		<value-of select="$default-atts"/>
       
    13 		<call-template name="all-atts"/>
       
    14 	</param>
       
    15 	<param name="labels"><if test="starts-with($atts,$default-atts)">Module,Layer,Block,Sub-block,Collection,Component</if></param>
       
    16 	
       
    17 
       
    18 <key name="tech" match="group[@type='color']/cbox" use="@style-id"/>
       
    19   
       
    20   
       
    21   <template name="all-atts">
       
    22   <variable name="all">
       
    23   	<apply-templates select="//layer/@* | //block/@*| //subblock/@*| //collection/@*| //component/@*" mode="atts">
       
    24 			<sort select="name()"/>
       
    25 		</apply-templates>
       
    26 	</variable>
       
    27 	<for-each select="set:distinct(exslt:node-set($all)/*/@v)">
       
    28 		<sort select="."/>,<value-of select="."/>
       
    29 	</for-each>
       
    30   </template>
       
    31   
       
    32 <template name="labels"><param name="at" select="$atts"/><param name="label" select="$labels"/>
       
    33 	<variable name="At">
       
    34 		<choose>
       
    35 			<when test="contains($at,',')"><value-of select="substring-before($at,',')"/></when>
       
    36 			<otherwise><value-of select="$at"/></otherwise>
       
    37 		</choose>
       
    38 	</variable>
       
    39 	<variable name="Lab">
       
    40 		<choose>
       
    41 			<when test="contains($label,',')"><value-of select="substring-before($label,',')"/></when>
       
    42 			<otherwise><value-of select="$label"/></otherwise>
       
    43 		</choose>
       
    44 	</variable>
       
    45 	<choose>
       
    46 		<when test="not(contains($at,',')) and $Lab!=''"><value-of select="$Lab"/></when> <!-- at end of list, use label  -->
       
    47 		<when test="not(contains($at,','))"><value-of select="$At"/></when><!-- at end of list-->
       
    48 		<when test="$Lab!=''">
       
    49 			<value-of select="$Lab"/><text>,</text>
       
    50 			<call-template name="labels">
       
    51 				<with-param name="at" select="substring-after($at,',')"/>
       
    52 				<with-param name="label" select="substring-after($label,',')"/>
       
    53 			</call-template>
       
    54 		</when>
       
    55 		<otherwise>
       
    56 			<value-of select="$At"/><text>,</text>
       
    57 			<call-template name="labels">
       
    58 				<with-param name="at" select="substring-after($at,',')"/>
       
    59 				<with-param name="label" select="substring-after($label,',')"/>
       
    60 			</call-template>
       
    61 		</otherwise>
       
    62 	</choose>
       
    63 </template>
       
    64   
       
    65 <template match="/SystemDefinition"><call-template name="labels"/>
       
    66 	<text>&#xa;</text>
       
    67  <apply-templates select="systemModel/layer//component"/>
       
    68 </template> 
       
    69 
       
    70 <template match="component">
       
    71 	<call-template name="others"/>
       
    72 	<text>&#xa;</text>
       
    73 </template> 
       
    74 
       
    75 <template match="*" mode="name"><apply-templates select="@name" mode="name"/></template>
       
    76 <!-- <template match="@*" mode="name">"<value-of select="."/>"</template>
       
    77 <template match="@*[contains(.,',')]" mode="name" priority="9">"<value-of select="."/>"</template>
       
    78 -->
       
    79 <template match="@*" mode="name" priority="7">"<value-of select="."/>"</template>
       
    80 <template match="@*[not(contains(.,','))]" mode="name" priority="8"><value-of select="."/></template>
       
    81 
       
    82 <template match="@*" mode="atts" priority="-1">
       
    83 	<element name="a"><attribute name="v"><value-of select="name()"/></attribute></element>
       
    84 </template>
       
    85 
       
    86 <!--template match="@name|@old_layer|@old_package|@id|@abbrev|@plugin|@introduced|@span|@levels|@level|@tech_domain|@platform_optional|@reason" mode="atts"/-->
       
    87 <template match="@name|@abbrev" mode="atts"/>
       
    88 
       
    89 <template name="others"><param name="at" select="$atts"/>
       
    90 	<variable name="a">
       
    91 		<choose>
       
    92 			<when test="contains($at,',')"><value-of select="substring-before($at,',')"/></when>
       
    93 			<otherwise><value-of select="$at"/></otherwise>
       
    94 		</choose>
       
    95 	</variable>
       
    96 	<choose>
       
    97 		<when test="$a='module' and @module"><apply-templates select="@module" mode="name"/></when>
       
    98 		<when test="$a='module'"><apply-templates select="ancestor::*[self::block or self::subblock][1]" mode="name"/></when>
       
    99 		<when test="$a='layer'"><apply-templates select="ancestor::layer" mode="name"/></when>
       
   100 		<when test="$a='block'"><apply-templates select="ancestor::block" mode="name"/></when>
       
   101 		<when test="$a='subblock'"><apply-templates select="ancestor::subblock" mode="name"/></when>
       
   102 		<when test="$a='collection'"><apply-templates select="ancestor::collection" mode="name"/></when>
       
   103 		<when test="$a='component'"><apply-templates select="." mode="name"/></when>
       
   104 		<when test="$a='old_component'"><if test="@old_component!=@name"><apply-templates select="@old_component" mode="name"/></if></when>
       
   105 		<when test="$a='tech_domain'">"<value-of select="ancestor-or-self::*/@tech_domain"/>"</when>
       
   106 		<when test="$a='level'"><value-of select="ancestor-or-self::collection/@level"/></when>
       
   107 		<when test="$a='levels'">"<value-of select="ancestor-or-self::block/@levels"/>"</when>
       
   108 		<when test="$a='layer-levels'">"<value-of select="ancestor-or-self::layer/@levels"/>"</when>
       
   109 		<when test="$a='block-level'"><value-of select="ancestor-or-self::block/@level"/></when>
       
   110 		<when test="$a='long-name'"><apply-templates mode="name" select="@long-name"/></when>
       
   111 		<when test="@*[name()=$a]"><apply-templates select="@*[name()=$a]" mode="name"/></when>
       
   112 		<when test="ancestor::collection/@*[name()=$a]"><apply-templates select="ancestor::collection/@*[name()=$a]" mode="name"/></when>
       
   113 		<when test="ancestor::subblock/@*[name()=$a]"><apply-templates select="ancestor::subblock/@*[name()=$a]" mode="name"/></when>
       
   114 		<when test="ancestor::block/@*[name()=$a]"><apply-templates select="ancestor::block/@*[name()=$a]" mode="name"/></when>
       
   115 		<otherwise><apply-templates select="ancestor::layer/@*[name()=$a]" mode="name"/></otherwise>
       
   116 	</choose>
       
   117 	<if test="contains($at,',')">
       
   118 		<text>,</text>
       
   119 		<call-template name="others">
       
   120 			<with-param name="at" select="substring-after($at,',')"/>
       
   121 		</call-template>
       
   122 	</if>
       
   123 </template>
       
   124 
       
   125 </stylesheet>