comparison html.xsl @ 60:588cb9ba7c9c

display of reffed info via colour minimally working
author Henry S. Thompson <ht@markup.co.uk>
date Fri, 02 Jun 2017 15:50:43 +0100
parents f90bbd38b8f6
children 2da454c30b47
comparison
equal deleted inserted replaced
59:f90bbd38b8f6 60:588cb9ba7c9c
5 <xsl:output omit-xml-declaration="yes"/> 5 <xsl:output omit-xml-declaration="yes"/>
6 6
7 <xsl:include href="n2a.xsl"/> 7 <xsl:include href="n2a.xsl"/>
8 8
9 <xsl:variable name="colours" select="( 9 <xsl:variable name="colours" select="(
10 '#FFB300', /* Vivid Yellow */ 10 (: Thanks to http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors :)
11 '#803E75', /* Strong Purple */ 11 '#FFB300', (: Vivid Yellow :)
12 '#FF6800', /* Vivid Orange */ 12 '#803E75', (: Strong Purple :)
13 '#A6BDD7', /* Very Light Blue */ 13 '#FF6800', (: Vivid Orange :)
14 '#C10020', /* Vivid Red */ 14 '#A6BDD7', (: Very Light Blue :)
15 '#CEA262', /* Grayish Yellow */ 15 '#C10020', (: Vivid Red :)
16 '#817066', /* Medium Gray */ 16 '#CEA262', (: Grayish Yellow :)
17 /* The following don't work well for people with defective color vision */ 17 '#817066', (: Medium Gray :)
18 '#007D34', /* Vivid Green */ 18 (: The following don't work well for people with defective color vision :)
19 '#F6768E', /* Strong Purplish Pink */ 19 '#007D34', (: Vivid Green :)
20 '#00538A', /* Strong Blue */ 20 '#F6768E', (: Strong Purplish Pink :)
21 '#FF7A5C', /* Strong Yellowish Pink */ 21 '#00538A', (: Strong Blue :)
22 '#53377A', /* Strong Violet */ 22 '#FF7A5C', (: Strong Yellowish Pink :)
23 '#FF8E00', /* Vivid Orange Yellow */ 23 '#53377A', (: Strong Violet :)
24 '#B32851', /* Strong Purplish Red */ 24 '#FF8E00', (: Vivid Orange Yellow :)
25 '#F4C800', /* Vivid Greenish Yellow */ 25 '#B32851', (: Strong Purplish Red :)
26 '#7F180D', /* Strong Reddish Brown */ 26 '#F4C800', (: Vivid Greenish Yellow :)
27 '#93AA00', /* Vivid Yellowish Green */ 27 '#7F180D', (: Strong Reddish Brown :)
28 '#593315', /* Deep Yellowish Brown */ 28 '#93AA00', (: Vivid Yellowish Green :)
29 '#F13A13', /* Vivid Reddish Orange */ 29 '#593315', (: Deep Yellowish Brown :)
30 '#232C16' /* Dark Olive Green */)"><xsl:comment>From http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors</xsl:comment></xsl:variable> 30 '#F13A13', (: Vivid Reddish Orange :)
31 '#232C16' (: Dark Olive Green :))"/>
31 <xsl:variable name="nColours" select="count($colours)"/> 32 <xsl:variable name="nColours" select="count($colours)"/>
32 <xsl:variable name="colourClassStyles" select="for $c in colours, $i in (1 to $nColours) return concat('.c',$i,' {background-color: ',$c,'}')"/> 33 <xsl:variable name="colourClassStyles" select="for $i in (1 to $nColours) return concat('.c',$i,' {background-color: ',$colours[$i],'}')"/>
34
35 <xsl:variable name="backfi" select="distinct-values(/e:a/e:r/e:c/e:i/@ri)"/>
36 <xsl:variable name="borderClassStyles" select="for $fis in $backfi return e:bcs($fis)"></xsl:variable>
33 37
34 <xsl:template match="/"> 38 <xsl:template match="/">
35 <html> 39 <html>
36 <head> 40 <head>
37 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> 41 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
42 .formula {font-style: italic} 46 .formula {font-style: italic}
43 .reffed {border: solid 1px black} 47 .reffed {border: solid 1px black}
44 table {table-layout: fixed} 48 table {table-layout: fixed}
45 th {width: 1en} 49 th {width: 1en}
46 </style> 50 </style>
47 <style><xsl:value-of select="string-join($colourClassStyles,'&#10; "/></style> 51 <style><xsl:value-of select="string-join($colourClassStyles,'&#10; ')"/></style>
52 <style><xsl:value-of select="string-join($borderClassStyles,'&#10; ')"/></style>
48 </head> 53 </head>
49 <body> 54 <body>
50 <xsl:apply-templates/> 55 <xsl:apply-templates/>
51 </body> 56 </body>
52 </html> 57 </html>
97 </td> 102 </td>
98 </xsl:template> 103 </xsl:template>
99 104
100 <xsl:variable name="borders" select="('left','right','top','bottom')"/> 105 <xsl:variable name="borders" select="('left','right','top','bottom')"/>
101 106
107 <xsl:function name="e:bcs" as="xs:string">
108 <xsl:param name="fiss" as="xs:string"/>
109 <xsl:value-of select="let $fis := tokenize($fiss,'_') return
110 concat('.b',$fiss,' {',
111 string-join(for $i in (1 to 4) return
112 e:bfs($fis[$i],
113 $borders[$i]),
114 '; '),
115 '}')"/>
116 </xsl:function>
117
118 <xsl:function name="e:bfs" as="xs:string">
119 <xsl:param name="fi" as="xs:string?"/>
120 <xsl:param name="pos" as="xs:string"/>
121 <xsl:value-of select="if (empty($fi)) then
122 concat('border-',$pos,': solid 1px black') else
123 concat('border-',$pos,': solid 2px ',
124 $colours[xs:integer($fi)])"/>
125 </xsl:function>
126
102 <xsl:function name="e:rf" as="xs:string"> 127 <xsl:function name="e:rf" as="xs:string">
103 <xsl:param name="ris" as="attribute(ri)*"/> 128 <xsl:param name="ris" as="attribute(ri)*"/>
104 <xsl:value-of select="let $ff := (for $ri in split($ris,',') 129 <xsl:value-of select="let $ff := (for $ri in tokenize(string($ris),'_')
105 return if ($ri le $nColours) then $ri else ()) 130 return if (xs:integer($ri) le $nColours) then $ri else ())
106 return if $ff 131 return if (empty($ff))
107 then concat('.b',string-join($ff,'b')) 132 then 'reffed'
108 else 'reffed'"/> 133 else concat('b',
134 string-join(subsequence($ff,1,4),'_'))"/>
109 </xsl:function> 135 </xsl:function>
110 </xsl:stylesheet> 136 </xsl:stylesheet>