|
1 <?xml version="1.0" encoding="UTF-8"?> |
|
2 <!-- |
|
3 Relational pipes |
|
4 Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
|
5 |
|
6 This program is free software: you can redistribute it and/or modify |
|
7 it under the terms of the GNU General Public License as published by |
|
8 the Free Software Foundation, version 3 of the License. |
|
9 |
|
10 This program is distributed in the hope that it will be useful, |
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 GNU General Public License for more details. |
|
14 |
|
15 You should have received a copy of the GNU General Public License |
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 --> |
|
18 <xsl:stylesheet version="1.0" |
|
19 xmlns="http://www.w3.org/1999/xhtml" |
|
20 xmlns:h="http://www.w3.org/1999/xhtml" |
|
21 xmlns:rp="tag:globalcode.info,2018:relpipe" |
|
22 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
|
23 xmlns:fn="http://www.w3.org/2005/xpath-functions" |
|
24 xmlns:svg="http://www.w3.org/2000/svg" |
|
25 xmlns:xs="http://www.w3.org/2001/XMLSchema" |
|
26 exclude-result-prefixes="fn h rp xs"> |
|
27 <xsl:output |
|
28 method="xml" |
|
29 indent="yes" |
|
30 encoding="UTF-8" |
|
31 doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" |
|
32 doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/> |
|
33 |
|
34 <xsl:param name="title" select="'Relational pipes XHTML output'"/> |
|
35 |
|
36 |
|
37 <!-- |
|
38 TODO: |
|
39 Parameters: |
|
40 title / h1 |
|
41 introduction and footer for whole report |
|
42 introduction and footer for every relation |
|
43 custom CSS + optionaly remove default CSS |
|
44 custom JavaScript |
|
45 whether to display or hide types in table headers |
|
46 whether to insert CSS classes for data types in each <td/> |
|
47 custom pre regex (see below) |
|
48 metadata relation name (will be hidden and we will get texts or custom titles for particular relations) |
|
49 |
|
50 CSS: |
|
51 clean-up, better style |
|
52 attribute name |
|
53 attribute type |
|
54 relation name |
|
55 table class for each relation (if [a-zA-Z0-9]+) |
|
56 --> |
|
57 |
|
58 <xsl:template match="/"> |
|
59 <html> |
|
60 <head> |
|
61 <title> |
|
62 <xsl:value-of select="$title"/> |
|
63 </title> |
|
64 <meta name="generator" content="Relational pipes: https://relational-pipes.globalcode.info/"/> |
|
65 <style type="text/css"> |
|
66 body { |
|
67 font-family: sans; |
|
68 background-color: #eee; |
|
69 color: black; |
|
70 padding-left: 20px; |
|
71 } |
|
72 |
|
73 p { |
|
74 max-width: 800px; |
|
75 } |
|
76 |
|
77 h1,h2 { |
|
78 max-width: 800px; |
|
79 border-radius: 8px; |
|
80 border: 1px solid #ddd; |
|
81 background-color: #e8e8e8; |
|
82 padding: 6px; |
|
83 text-shadow: 2px 2px 2px #aaa; |
|
84 } |
|
85 |
|
86 h1 { |
|
87 font-size: 150% |
|
88 } |
|
89 h2 { |
|
90 font-size: 100%; |
|
91 font-weight: bold; |
|
92 } |
|
93 |
|
94 pre,code { |
|
95 color: #a00; |
|
96 } |
|
97 |
|
98 table { |
|
99 border-collapse:collapse; |
|
100 box-shadow: 3px 3px 3px grey; |
|
101 margin-top: 10px; |
|
102 margin-bottom: 10px; |
|
103 } |
|
104 td, th { |
|
105 border: 1px solid black; |
|
106 padding-top: 4px; |
|
107 padding-bottom: 4px; |
|
108 padding-left: 6px; |
|
109 padding-right: 6px; |
|
110 font-weight: normal; |
|
111 } |
|
112 td.type_integer,td.type_boolean { |
|
113 text-align: right; |
|
114 } |
|
115 thead tr { |
|
116 background: #aaa; |
|
117 color:black; |
|
118 } |
|
119 tbody tr:hover { |
|
120 background-color: silver; |
|
121 color:black; |
|
122 } |
|
123 |
|
124 </style> |
|
125 </head> |
|
126 <body> |
|
127 <h1> |
|
128 <xsl:value-of select="$title"/> |
|
129 </h1> |
|
130 |
|
131 <p> |
|
132 This is output of <code>relpipe-out-xml</code> converted to XHTML web page. |
|
133 </p> |
|
134 |
|
135 <xsl:for-each select="/rp:relpipe/rp:relation"> |
|
136 <h2> |
|
137 <xsl:value-of select="rp:name"/> |
|
138 </h2> |
|
139 |
|
140 <table> |
|
141 <thead> |
|
142 <tr> |
|
143 <xsl:for-each select="rp:attributes-metadata/rp:attribute-metadata"> |
|
144 <td> |
|
145 <xsl:value-of select="@name"/> |
|
146 <xsl:text> (</xsl:text> |
|
147 <xsl:value-of select="@type"/> |
|
148 <xsl:text>)</xsl:text> |
|
149 </td> |
|
150 </xsl:for-each> |
|
151 </tr> |
|
152 </thead> |
|
153 <tbody> |
|
154 <xsl:for-each select="rp:record"> |
|
155 <tr> |
|
156 <xsl:for-each select="rp:attribute"> |
|
157 <xsl:variable name="column" select="position()"/> |
|
158 <!-- TODO: wrap in <pre/> for relations/attributes matching a regular expression passed as a XSLT parameter e.g. „relation1:attribute1|relation2:attribute3“ --> |
|
159 <td class="type_{../../rp:attributes-metadata/rp:attribute-metadata[$column]/@type}"> |
|
160 <xsl:apply-templates/> |
|
161 </td> |
|
162 </xsl:for-each> |
|
163 </tr> |
|
164 </xsl:for-each> |
|
165 </tbody> |
|
166 </table> |
|
167 |
|
168 </xsl:for-each> |
|
169 |
|
170 </body> |
|
171 </html> |
|
172 </xsl:template> |
|
173 |
|
174 </xsl:stylesheet> |