xml/config.xsl
author František Kučera <franta-hg@frantovo.cz>
Fri, 03 Jan 2014 21:36:00 +0100
branchv_0
changeset 123 248a98c13ca4
parent 119 f3e2b95a5f8a
child 198 03d8492e2ca8
permissions -rw-r--r--
TabularWrappingFormatter – first version
     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, either version 3 of the License, or
     9 (at your option) any later version.
    10 
    11 This program is distributed in the hope that it will be useful,
    12 but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    14 GNU General Public License for more details.
    15 
    16 You should have received a copy of the GNU General Public License
    17 along with this program. If not, see <http://www.gnu.org/licenses/>.
    18 -->
    19 
    20 <!--
    21 	This XSLT can be used for viewing config files in a web browser (Firefox, rekonq etc.)
    22 -->
    23 
    24 <xsl:stylesheet version="1.0"
    25 	xmlns="http://www.w3.org/1999/xhtml"
    26 	xmlns:h="http://www.w3.org/1999/xhtml"
    27 	xmlns:c="https://sql-dk.globalcode.info/xmlns/configuration"
    28 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    29 	xmlns:fn="http://www.w3.org/2005/xpath-functions"
    30 	xmlns:svg="http://www.w3.org/2000/svg"
    31 	xmlns:xs="http://www.w3.org/2001/XMLSchema"
    32 	exclude-result-prefixes="fn h p xs">
    33 	<xsl:output
    34 		method="xml"
    35 		indent="yes"
    36 		encoding="UTF-8"
    37 		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    38 		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
    39 		
    40 	<xsl:param name="header" select="'SQL-DK configuration'"/>
    41 	
    42 	<xsl:template match="/">
    43 		<html>
    44 			<head>
    45 				<title><xsl:value-of select="$header"/></title>
    46 				<style type="text/css">
    47 					body {
    48 						font-family: sans;
    49 						background-color: #eee;
    50 						color: black;
    51 						padding-left: 20px;
    52 					}
    53 					
    54 					p {
    55 						max-width: 800px;
    56 					}
    57 					
    58 					h1,h2 {
    59 						max-width: 800px;
    60 						border-radius: 8px;
    61 						border: 1px solid #ddd;
    62 						background-color: #e8e8e8;
    63 						padding: 6px;
    64 						text-shadow: 2px 2px 2px #aaa;
    65 					}
    66 					
    67 					h1 {
    68 						font-size: 150%
    69 					}
    70 					
    71 					h2 {
    72 						font-size: 100%;
    73 						font-weight: bold;
    74 					}
    75 					
    76 					table {
    77 						border-collapse:collapse;
    78 						margin-top: 10px;
    79 						margin-bottom: 10px;
    80 					}
    81 					td, th {
    82 						border: 1px solid #ddd;
    83 						padding-top: 4px;
    84 						padding-bottom: 4px;
    85 						padding-left: 6px;
    86 						padding-right: 6px;
    87 						font-weight: normal;
    88 						vertical-align: top;
    89 					}
    90 					thead tr {
    91 						background: #e8e8e8;
    92 						color:black;
    93 					}
    94 					tbody tr:hover {
    95 						background-color: #e9e9e9;
    96 						color:black;
    97 					}
    98 					
    99 					ul {
   100 						margin: 0px;
   101 					}
   102 					
   103 					li {
   104 						padding: 0px;
   105 					}
   106 				</style>
   107 			</head>
   108 			<body>
   109 				<h1><xsl:value-of select="$header"/></h1>
   110 				
   111 				<p>
   112 					This file defines per-user configuration of <a href="https://sql-dk.globalcode.info/">SQL-DK</a>
   113 					– an SQL batch client.
   114 				</p>
   115 				
   116 				
   117 				<h2>Database connections</h2>
   118 				
   119 				<p>This databases are configured:</p>
   120 				
   121 				<xsl:choose>
   122 					<xsl:when test="c:configuration/c:database">
   123 						<table>
   124 							<thead>
   125 								<tr>
   126 									<td>name</td>
   127 									<td>username</td>
   128 									<td>url</td>
   129 									<td>properties</td>
   130 								</tr>
   131 							</thead>
   132 							<tbody>
   133 								<xsl:for-each select="c:configuration/c:database">
   134 									<tr>
   135 									<td><xsl:value-of select="c:name"/></td>
   136 									<td><xsl:value-of select="c:userName"/></td>
   137 									<td><xsl:value-of select="c:url"/></td>
   138 									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   139 								</tr>
   140 								</xsl:for-each>
   141 							</tbody>
   142 						</table>
   143 					</xsl:when>
   144 					<xsl:otherwise><p>no databases are configured</p></xsl:otherwise>
   145 				</xsl:choose>
   146 				
   147 				<p>(passwords are hidden in this output)</p>
   148 				
   149 				
   150 				<h2>Output formatters</h2>
   151 				
   152 				<p>
   153 					Default formatter: 
   154 					<xsl:choose>
   155 						<xsl:when test="c:configuration/c:defaultFormatter"><xsl:value-of select="c:configuration/c:defaultFormatter"/></xsl:when>
   156 						<xsl:otherwise>none (built-in default will be used)</xsl:otherwise>
   157 					</xsl:choose>
   158 				</p>
   159 				
   160 				<xsl:choose>
   161 					<xsl:when test="c:configuration/c:formatter">
   162 						<table>
   163 							<thead>
   164 								<tr>
   165 									<td>name</td>
   166 									<td>class name</td>
   167 									<td>properties</td>
   168 								</tr>
   169 							</thead>
   170 							<tbody>
   171 								<xsl:for-each select="c:configuration/c:formatter">
   172 									<tr>
   173 									<td><xsl:value-of select="c:name"/></td>
   174 									<td><xsl:value-of select="c:class"/></td>
   175 									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   176 								</tr>
   177 								</xsl:for-each>
   178 							</tbody>
   179 						</table>
   180 					</xsl:when>
   181 					<xsl:otherwise><p>no additional formatters are defined (built-in defaults will be used)</p></xsl:otherwise>
   182 				</xsl:choose>
   183 				
   184 			</body>
   185 		</html>
   186 	</xsl:template>
   187 	
   188 	<xsl:template match="c:property">
   189 		<li>
   190 			<xsl:value-of select="@name"/> = <xsl:value-of select="."/>
   191 		</li>
   192 	</xsl:template>
   193 
   194 </xsl:stylesheet>