xml/config.xsl
author František Kučera <franta-hg@frantovo.cz>
Sun, 04 Feb 2024 16:10:37 +0100
branchv_0
changeset 255 099bb96f8d8d
parent 250 aae5009bd0af
permissions -rw-r--r--
tabular formatter: new option 'separateBy' to print horizontal separator on each change of given column
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!--
     3 SQL-DK
     4 Copyright © 2013 František Kučera (frantovo.cz)
     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 
    19 <!--
    20 	This XSLT can be used for viewing config files in a web browser (Firefox, rekonq etc.)
    21 -->
    22 
    23 <xsl:stylesheet version="1.0"
    24 	xmlns="http://www.w3.org/1999/xhtml"
    25 	xmlns:h="http://www.w3.org/1999/xhtml"
    26 	xmlns:c="tag:globalcode.info,2018:sqldk/configuration"
    27 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    28 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
    29 	xmlns:svg="http://www.w3.org/2000/svg"
    30 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
    31 	exclude-result-prefixes="fn h p xs">
    32 	<xsl:output
    33 		method="xml"
    34 		indent="yes"
    35 		encoding="UTF-8"
    36 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    37 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
    38 		
    39 	<xsl:param name="header" select="'SQL-DK configuration'"/>
    40 	
    41 	<xsl:template match="/">
    42 		<html>
    43 			<head>
    44 				<title><xsl:value-of select="$header"/></title>
    45 				<style type="text/css">
    46 					body {
    47 						font-family: sans;
    48 						background-color: #eee;
    49 						color: black;
    50 						padding-left: 20px;
    51 					}
    52 					
    53 					p {
    54 						max-width: 800px;
    55 					}
    56 					
    57 					h1,h2 {
    58 						max-width: 800px;
    59 						border-radius: 8px;
    60 						border: 1px solid #ddd;
    61 						background-color: #e8e8e8;
    62 						padding: 6px;
    63 						text-shadow: 2px 2px 2px #aaa;
    64 					}
    65 					
    66 					h1 {
    67 						font-size: 150%
    68 					}
    69 					
    70 					h2 {
    71 						font-size: 100%;
    72 						font-weight: bold;
    73 					}
    74 					
    75 					table {
    76 						border-collapse:collapse;
    77 						margin-top: 10px;
    78 						margin-bottom: 10px;
    79 					}
    80 					td, th {
    81 						border: 1px solid #ddd;
    82 						padding-top: 4px;
    83 						padding-bottom: 4px;
    84 						padding-left: 6px;
    85 						padding-right: 6px;
    86 						font-weight: normal;
    87 						vertical-align: top;
    88 					}
    89 					thead tr {
    90 						background: #e8e8e8;
    91 						color:black;
    92 					}
    93 					tbody tr:hover {
    94 						background-color: #e9e9e9;
    95 						color:black;
    96 					}
    97 					
    98 					ul {
    99 						margin: 0px;
   100 					}
   101 					
   102 					li {
   103 						padding: 0px;
   104 					}
   105 					
   106 					.notes {
   107 						font-size: 66%;
   108 					}
   109 					.notes p {
   110 						margin-bottom: 0px;
   111 					}
   112 				</style>
   113 			</head>
   114 			<body>
   115 				<h1><xsl:value-of select="$header"/></h1>
   116 				
   117 				<p>
   118 					This file defines per-user configuration of <a href="https://sql-dk.globalcode.info/">SQL-DK</a>
   119 					– an SQL batch client.
   120 				</p>
   121 				
   122 				
   123 				<h2>Database connections</h2>
   124 				
   125 				<p>This databases are configured:</p>
   126 				
   127 				<xsl:choose>
   128 					<xsl:when test="c:configuration/c:database">
   129 						<table>
   130 							<thead>
   131 								<tr>
   132 									<td>name</td>
   133 									<td>username</td>
   134 									<td>url</td>
   135 									<td>JDBC driver</td>
   136 									<td>properties</td>
   137 								</tr>
   138 							</thead>
   139 							<tbody>
   140 								<xsl:for-each select="c:configuration/c:database">
   141 									<tr>
   142 									<td><xsl:value-of select="c:name"/></td>
   143 									<td><xsl:value-of select="c:userName"/></td>
   144 									<td><xsl:value-of select="c:url"/></td>
   145 									<td><xsl:value-of select="c:driver"/></td>
   146 									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   147 								</tr>
   148 								</xsl:for-each>
   149 							</tbody>
   150 						</table>
   151 					</xsl:when>
   152 					<xsl:otherwise><p>no databases are configured</p></xsl:otherwise>
   153 				</xsl:choose>
   154 				
   155 				<div class="notes">
   156 					<p>Notes:</p>
   157 					<ul>
   158 						<li>passwords are hidden in this output</li>
   159 						<li>JDBC drivers are not mandatory – not needed in SQL-DK, but sometimes useful when <code>jdbc-dk-driver</code> is used in other applications to load SQL-DK's database connections</li>
   160 					</ul>
   161 				</div>
   162 				
   163 				
   164 				<h2>Output formatters</h2>
   165 				
   166 				<p>
   167 					Default formatter: 
   168 					<xsl:choose>
   169 						<xsl:when test="c:configuration/c:defaultFormatter"><xsl:value-of select="c:configuration/c:defaultFormatter"/></xsl:when>
   170 						<xsl:otherwise>none (built-in default will be used)</xsl:otherwise>
   171 					</xsl:choose>
   172 				</p>
   173 				
   174 				<xsl:choose>
   175 					<xsl:when test="c:configuration/c:formatter">
   176 						<table>
   177 							<thead>
   178 								<tr>
   179 									<td>name</td>
   180 									<td>class name</td>
   181 									<td>properties</td>
   182 								</tr>
   183 							</thead>
   184 							<tbody>
   185 								<xsl:for-each select="c:configuration/c:formatter">
   186 									<tr>
   187 									<td><xsl:value-of select="c:name"/></td>
   188 									<td><xsl:value-of select="c:class"/></td>
   189 									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   190 								</tr>
   191 								</xsl:for-each>
   192 							</tbody>
   193 						</table>
   194 					</xsl:when>
   195 					<xsl:otherwise><p>no additional formatters are defined (built-in defaults will be used)</p></xsl:otherwise>
   196 				</xsl:choose>
   197 				
   198 			</body>
   199 		</html>
   200 	</xsl:template>
   201 	
   202 	<xsl:template match="c:property">
   203 		<li>
   204 			<xsl:value-of select="@name"/> = <xsl:value-of select="."/>
   205 		</li>
   206 	</xsl:template>
   207 
   208 </xsl:stylesheet>