comparison html.xsl @ 59:f90bbd38b8f6

towards display of reffed info via colour
author Henry S. Thompson <ht@markup.co.uk>
date Fri, 02 Jun 2017 12:54:54 +0100
parents 01a7c2ebd3d1
children 588cb9ba7c9c
comparison
equal deleted inserted replaced
58:adeb9575b273 59:f90bbd38b8f6
3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:s="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs s xpf e" xmlns="http://www.w3.org/1999/xhtml" xmlns:xpf="http://www.w3.org/2005/xpath-functions"> 3 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:s="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:e="http://markup.co.uk/excel" exclude-result-prefixes="xs s xpf e" xmlns="http://www.w3.org/1999/xhtml" xmlns:xpf="http://www.w3.org/2005/xpath-functions">
4 <xsl:strip-space elements="e:a"/> 4 <xsl:strip-space elements="e:a"/>
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
9 <xsl:variable name="colours" select="(
10 '#FFB300', /* Vivid Yellow */
11 '#803E75', /* Strong Purple */
12 '#FF6800', /* Vivid Orange */
13 '#A6BDD7', /* Very Light Blue */
14 '#C10020', /* Vivid Red */
15 '#CEA262', /* Grayish Yellow */
16 '#817066', /* Medium Gray */
17 /* The following don't work well for people with defective color vision */
18 '#007D34', /* Vivid Green */
19 '#F6768E', /* Strong Purplish Pink */
20 '#00538A', /* Strong Blue */
21 '#FF7A5C', /* Strong Yellowish Pink */
22 '#53377A', /* Strong Violet */
23 '#FF8E00', /* Vivid Orange Yellow */
24 '#B32851', /* Strong Purplish Red */
25 '#F4C800', /* Vivid Greenish Yellow */
26 '#7F180D', /* Strong Reddish Brown */
27 '#93AA00', /* Vivid Yellowish Green */
28 '#593315', /* Deep Yellowish Brown */
29 '#F13A13', /* Vivid Reddish Orange */
30 '#232C16' /* Dark Olive Green */)"><xsl:comment>From http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors</xsl:comment></xsl:variable>
31 <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,'}')"/>
8 33
9 <xsl:template match="/"> 34 <xsl:template match="/">
10 <html> 35 <html>
11 <head> 36 <head>
12 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> 37 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
16 .e {color: red} 41 .e {color: red}
17 .formula {font-style: italic} 42 .formula {font-style: italic}
18 .reffed {border: solid 1px black} 43 .reffed {border: solid 1px black}
19 table {table-layout: fixed} 44 table {table-layout: fixed}
20 th {width: 1en} 45 th {width: 1en}
21 /* http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors */
22 .c1 {background-color: #FFB300} /* Vivid Yellow */
23 .c2 {background-color: #803E75} /* Strong Purple */
24 .c3 {background-color: #FF6800} /* Vivid Orange */
25 .c4 {background-color: #A6BDD7} /* Very Light Blue */
26 .c5 {background-color: #C10020} /* Vivid Red */
27 .c6 {background-color: #CEA262} /* Grayish Yellow */
28 .c7 {background-color: #817066} /* Medium Gray */
29 /* The following don't work well for people with defective color vision */
30 .c8 {background-color: #007D34} /* Vivid Green */
31 .c9 {background-color: #F6768E} /* Strong Purplish Pink */
32 .c10 {background-color: #00538A} /* Strong Blue */
33 .c11 {background-color: #FF7A5C} /* Strong Yellowish Pink */
34 .c12 {background-color: #53377A} /* Strong Violet */
35 .c13 {background-color: #FF8E00} /* Vivid Orange Yellow */
36 .c14 {background-color: #B32851} /* Strong Purplish Red */
37 .c15 {background-color: #F4C800} /* Vivid Greenish Yellow */
38 .c16 {background-color: #7F180D} /* Strong Reddish Brown */
39 .c17 {background-color: #93AA00} /* Vivid Yellowish Green */
40 .c18 {background-color: #593315} /* Deep Yellowish Brown */
41 .c19 {background-color: #F13A13} /* Vivid Reddish Orange */
42 .c20 {background-color: #232C16} /* Dark Olive Green */
43 </style> 46 </style>
47 <style><xsl:value-of select="string-join($colourClassStyles,'&#10; "/></style>
44 </head> 48 </head>
45 <body> 49 <body>
46 <xsl:apply-templates/> 50 <xsl:apply-templates/>
47 </body> 51 </body>
48 </html> 52 </html>
72 <xsl:choose> 76 <xsl:choose>
73 <xsl:when test="@t|text()"> 77 <xsl:when test="@t|text()">
74 <xsl:attribute name="class"> 78 <xsl:attribute name="class">
75 <xsl:value-of select="(if (@t) then @t else text(), 79 <xsl:value-of select="(if (@t) then @t else text(),
76 if (e:f) then 'formula' else (), 80 if (e:f) then 'formula' else (),
77 if (e:i) then 'reffed' else (), 81 if (e:i) then e:rf(e:i/@ri) else (),
78 if (@fi) then concat('c',@fi) else ())"/> 82 if (@fi) then concat('c',@fi) else ())"/>
79 </xsl:attribute> 83 </xsl:attribute>
80 <xsl:attribute name="title"> 84 <xsl:attribute name="title">
81 <xsl:choose> 85 <xsl:choose>
82 <xsl:when test="e:i"> 86 <xsl:when test="e:i">
90 <xsl:value-of select="if (@t) then @t else text()"/></xsl:when> 94 <xsl:value-of select="if (@t) then @t else text()"/></xsl:when>
91 <xsl:otherwise></xsl:otherwise> 95 <xsl:otherwise></xsl:otherwise>
92 </xsl:choose> 96 </xsl:choose>
93 </td> 97 </td>
94 </xsl:template> 98 </xsl:template>
99
100 <xsl:variable name="borders" select="('left','right','top','bottom')"/>
101
102 <xsl:function name="e:rf" as="xs:string">
103 <xsl:param name="ris" as="attribute(ri)*"/>
104 <xsl:value-of select="let $ff := (for $ri in split($ris,',')
105 return if ($ri le $nColours) then $ri else ())
106 return if $ff
107 then concat('.b',string-join($ff,'b'))
108 else 'reffed'"/>
109 </xsl:function>
95 </xsl:stylesheet> 110 </xsl:stylesheet>