Mercurial > hg > ooxml
annotate html.xsl @ 51:793496d2d165
allow command line input
author | Henry S. Thompson <ht@markup.co.uk> |
---|---|
date | Tue, 16 May 2017 17:27:19 +0100 |
parents | 01a7c2ebd3d1 |
children | f90bbd38b8f6 |
rev | line source |
---|---|
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
1 <?xml version='1.0'?> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
2 <!DOCTYPE doc SYSTEM "../../../lib/xml/xsl.dtd" > |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
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"> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
4 <xsl:strip-space elements="e:a"/> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
5 <xsl:output omit-xml-declaration="yes"/> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
6 |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
7 <xsl:include href="n2a.xsl"/> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
8 |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
9 <xsl:template match="/"> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
10 <html> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
11 <head> |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
12 <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
13 <style> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
14 body {font-family: 'DejaVu Sans Mono' , monospace} |
16
2bbd067529b6
improve efficiency, detect blank rows, don't type empty cells
Henry S. Thompson <ht@markup.co.uk>
parents:
15
diff
changeset
|
15 td {padding: 0} |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
16 .e {color: red} |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
17 .formula {font-style: italic} |
19
9b1b169dc8db
use refs, but broken: doesn't deal with ranges (false negs) or external refs (false pos), and not finding things it should (e.g. kenneth_lay X88)
Henry S. Thompson <ht@markup.co.uk>
parents:
16
diff
changeset
|
18 .reffed {border: solid 1px black} |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
19 table {table-layout: fixed} |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
20 th {width: 1en} |
50
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
21 /* http://stackoverflow.com/questions/470690/how-to-automatically-generate-n-distinct-colors */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
22 .c1 {background-color: #FFB300} /* Vivid Yellow */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
23 .c2 {background-color: #803E75} /* Strong Purple */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
24 .c3 {background-color: #FF6800} /* Vivid Orange */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
25 .c4 {background-color: #A6BDD7} /* Very Light Blue */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
26 .c5 {background-color: #C10020} /* Vivid Red */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
27 .c6 {background-color: #CEA262} /* Grayish Yellow */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
28 .c7 {background-color: #817066} /* Medium Gray */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
29 /* The following don't work well for people with defective color vision */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
30 .c8 {background-color: #007D34} /* Vivid Green */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
31 .c9 {background-color: #F6768E} /* Strong Purplish Pink */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
32 .c10 {background-color: #00538A} /* Strong Blue */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
33 .c11 {background-color: #FF7A5C} /* Strong Yellowish Pink */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
34 .c12 {background-color: #53377A} /* Strong Violet */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
35 .c13 {background-color: #FF8E00} /* Vivid Orange Yellow */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
36 .c14 {background-color: #B32851} /* Strong Purplish Red */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
37 .c15 {background-color: #F4C800} /* Vivid Greenish Yellow */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
38 .c16 {background-color: #7F180D} /* Strong Reddish Brown */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
39 .c17 {background-color: #93AA00} /* Vivid Yellowish Green */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
40 .c18 {background-color: #593315} /* Deep Yellowish Brown */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
41 .c19 {background-color: #F13A13} /* Vivid Reddish Orange */ |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
42 .c20 {background-color: #232C16} /* Dark Olive Green */ |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
43 </style> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
44 </head> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
45 <body> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
46 <xsl:apply-templates/> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
47 </body> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
48 </html> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
49 </xsl:template> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
50 |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
51 <xsl:template match="e:a"> |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
52 <xsl:variable name="n" select="count(e:r[1]/e:c)"/> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
53 <table> |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
54 <thead> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
55 <tr> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
56 <xsl:for-each select="1 to $n"> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
57 <th/> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
58 </xsl:for-each> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
59 </tr> |
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
60 </thead> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
61 <tbody><xsl:apply-templates/></tbody> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
62 </table> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
63 </xsl:template> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
64 |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
65 <xsl:template match="e:r"> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
66 <tr><xsl:apply-templates/></tr> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
67 <xsl:text> </xsl:text> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
68 </xsl:template> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
69 |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
70 <xsl:template match="e:c"> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
71 <td> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
72 <xsl:choose> |
44
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
73 <xsl:when test="@t|text()"> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
74 <xsl:attribute name="class"> |
44
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
75 <xsl:value-of select="(if (@t) then @t else text(), |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
76 if (e:f) then 'formula' else (), |
50
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
77 if (e:i) then 'reffed' else (), |
01a7c2ebd3d1
top 20 shared formulae coloured in
Henry S. Thompson <ht@markup.co.uk>
parents:
44
diff
changeset
|
78 if (@fi) then concat('c',@fi) else ())"/> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
79 </xsl:attribute> |
44
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
80 <xsl:attribute name="title"> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
81 <xsl:choose> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
82 <xsl:when test="e:i"> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
83 <xsl:value-of select="e:i/@r"/>: <xsl:value-of select="e:i/e:r"/> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
84 </xsl:when> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
85 <xsl:otherwise> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
86 <xsl:value-of select="e:n2a(@c)"/><xsl:value-of select="../@r"/> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
87 </xsl:otherwise> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
88 </xsl:choose> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
89 </xsl:attribute> |
5b2333e59d91
updated html, ascii output to new raw doctype
Henry S. Thompson <ht@markup.co.uk>
parents:
34
diff
changeset
|
90 <xsl:value-of select="if (@t) then @t else text()"/></xsl:when> |
34
93fd0d532754
fix bug in refs wrt e.g. [1]!.SGX,
Henry S. Thompson <ht@markup.co.uk>
parents:
20
diff
changeset
|
91 <xsl:otherwise></xsl:otherwise> |
15
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
92 </xsl:choose> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
93 </td> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
94 </xsl:template> |
e767bef35bb9
default to ascii, but accept html.xsl for pretty
Henry S. Thompson <ht@markup.co.uk>
parents:
diff
changeset
|
95 </xsl:stylesheet> |