XSLT for viewing config files in a web browser (Firefox, rekonq etc.) v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Thu, 02 Jan 2014 21:23:23 +0100
branchv_0
changeset 119f3e2b95a5f8a
parent 118 cc9cd86188d2
child 120 940681695aa4
XSLT for viewing config files in a web browser (Firefox, rekonq etc.)
xml/config.xml
xml/config.xsl
     1.1 --- a/xml/config.xml	Thu Jan 02 20:32:59 2014 +0100
     1.2 +++ b/xml/config.xml	Thu Jan 02 21:23:23 2014 +0100
     1.3 @@ -1,4 +1,5 @@
     1.4  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     1.5 +<?xml-stylesheet type="text/xsl" href="config.xsl"?>
     1.6  <configuration xmlns="https://sql-dk.globalcode.info/xmlns/configuration">
     1.7  	
     1.8  	<!-- Database Connections: -->
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/xml/config.xsl	Thu Jan 02 21:23:23 2014 +0100
     2.3 @@ -0,0 +1,194 @@
     2.4 +<?xml version="1.0" encoding="UTF-8"?>
     2.5 +<!--
     2.6 +SQL-DK
     2.7 +Copyright © 2013 František Kučera (frantovo.cz)
     2.8 +
     2.9 +This program is free software: you can redistribute it and/or modify
    2.10 +it under the terms of the GNU General Public License as published by
    2.11 +the Free Software Foundation, either version 3 of the License, or
    2.12 +(at your option) any later version.
    2.13 +
    2.14 +This program is distributed in the hope that it will be useful,
    2.15 +but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.16 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    2.17 +GNU General Public License for more details.
    2.18 +
    2.19 +You should have received a copy of the GNU General Public License
    2.20 +along with this program. If not, see <http://www.gnu.org/licenses/>.
    2.21 +-->
    2.22 +
    2.23 +<!--
    2.24 +	This XSLT can be used for viewing config files in a web browser (Firefox, rekonq etc.)
    2.25 +-->
    2.26 +
    2.27 +<xsl:stylesheet version="1.0"
    2.28 +	xmlns="http://www.w3.org/1999/xhtml"
    2.29 +	xmlns:h="http://www.w3.org/1999/xhtml"
    2.30 +	xmlns:c="https://sql-dk.globalcode.info/xmlns/configuration"
    2.31 +	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    2.32 +	xmlns:fn="http://www.w3.org/2005/xpath-functions"
    2.33 +	xmlns:svg="http://www.w3.org/2000/svg"
    2.34 +	xmlns:xs="http://www.w3.org/2001/XMLSchema"
    2.35 +	exclude-result-prefixes="fn h p xs">
    2.36 +	<xsl:output
    2.37 +		method="xml"
    2.38 +		indent="yes"
    2.39 +		encoding="UTF-8"
    2.40 +		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
    2.41 +		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
    2.42 +		
    2.43 +	<xsl:param name="header" select="'SQL-DK configuration'"/>
    2.44 +	
    2.45 +	<xsl:template match="/">
    2.46 +		<html>
    2.47 +			<head>
    2.48 +				<title><xsl:value-of select="$header"/></title>
    2.49 +				<style type="text/css">
    2.50 +					body {
    2.51 +						font-family: sans;
    2.52 +						background-color: #eee;
    2.53 +						color: black;
    2.54 +						padding-left: 20px;
    2.55 +					}
    2.56 +					
    2.57 +					p {
    2.58 +						max-width: 800px;
    2.59 +					}
    2.60 +					
    2.61 +					h1,h2 {
    2.62 +						max-width: 800px;
    2.63 +						border-radius: 8px;
    2.64 +						border: 1px solid #ddd;
    2.65 +						background-color: #e8e8e8;
    2.66 +						padding: 6px;
    2.67 +						text-shadow: 2px 2px 2px #aaa;
    2.68 +					}
    2.69 +					
    2.70 +					h1 {
    2.71 +						font-size: 150%
    2.72 +					}
    2.73 +					
    2.74 +					h2 {
    2.75 +						font-size: 100%;
    2.76 +						font-weight: bold;
    2.77 +					}
    2.78 +					
    2.79 +					table {
    2.80 +						border-collapse:collapse;
    2.81 +						margin-top: 10px;
    2.82 +						margin-bottom: 10px;
    2.83 +					}
    2.84 +					td, th {
    2.85 +						border: 1px solid #ddd;
    2.86 +						padding-top: 4px;
    2.87 +						padding-bottom: 4px;
    2.88 +						padding-left: 6px;
    2.89 +						padding-right: 6px;
    2.90 +						font-weight: normal;
    2.91 +						vertical-align: top;
    2.92 +					}
    2.93 +					thead tr {
    2.94 +						background: #e8e8e8;
    2.95 +						color:black;
    2.96 +					}
    2.97 +					tbody tr:hover {
    2.98 +						background-color: #e9e9e9;
    2.99 +						color:black;
   2.100 +					}
   2.101 +					
   2.102 +					ul {
   2.103 +						margin: 0px;
   2.104 +					}
   2.105 +					
   2.106 +					li {
   2.107 +						padding: 0px;
   2.108 +					}
   2.109 +				</style>
   2.110 +			</head>
   2.111 +			<body>
   2.112 +				<h1><xsl:value-of select="$header"/></h1>
   2.113 +				
   2.114 +				<p>
   2.115 +					This file defines per-user configuration of <a href="https://sql-dk.globalcode.info/">SQL-DK</a>
   2.116 +					– an SQL batch client.
   2.117 +				</p>
   2.118 +				
   2.119 +				
   2.120 +				<h2>Database connections</h2>
   2.121 +				
   2.122 +				<p>This databases are configured:</p>
   2.123 +				
   2.124 +				<xsl:choose>
   2.125 +					<xsl:when test="c:configuration/c:database">
   2.126 +						<table>
   2.127 +							<thead>
   2.128 +								<tr>
   2.129 +									<td>name</td>
   2.130 +									<td>username</td>
   2.131 +									<td>url</td>
   2.132 +									<td>properties</td>
   2.133 +								</tr>
   2.134 +							</thead>
   2.135 +							<tbody>
   2.136 +								<xsl:for-each select="c:configuration/c:database">
   2.137 +									<tr>
   2.138 +									<td><xsl:value-of select="c:name"/></td>
   2.139 +									<td><xsl:value-of select="c:userName"/></td>
   2.140 +									<td><xsl:value-of select="c:url"/></td>
   2.141 +									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   2.142 +								</tr>
   2.143 +								</xsl:for-each>
   2.144 +							</tbody>
   2.145 +						</table>
   2.146 +					</xsl:when>
   2.147 +					<xsl:otherwise><p>no databases are configured</p></xsl:otherwise>
   2.148 +				</xsl:choose>
   2.149 +				
   2.150 +				<p>(passwords are hidden in this output)</p>
   2.151 +				
   2.152 +				
   2.153 +				<h2>Output formatters</h2>
   2.154 +				
   2.155 +				<p>
   2.156 +					Default formatter: 
   2.157 +					<xsl:choose>
   2.158 +						<xsl:when test="c:configuration/c:defaultFormatter"><xsl:value-of select="c:configuration/c:defaultFormatter"/></xsl:when>
   2.159 +						<xsl:otherwise>none (built-in default will be used)</xsl:otherwise>
   2.160 +					</xsl:choose>
   2.161 +				</p>
   2.162 +				
   2.163 +				<xsl:choose>
   2.164 +					<xsl:when test="c:configuration/c:formatter">
   2.165 +						<table>
   2.166 +							<thead>
   2.167 +								<tr>
   2.168 +									<td>name</td>
   2.169 +									<td>class name</td>
   2.170 +									<td>properties</td>
   2.171 +								</tr>
   2.172 +							</thead>
   2.173 +							<tbody>
   2.174 +								<xsl:for-each select="c:configuration/c:formatter">
   2.175 +									<tr>
   2.176 +									<td><xsl:value-of select="c:name"/></td>
   2.177 +									<td><xsl:value-of select="c:class"/></td>
   2.178 +									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
   2.179 +								</tr>
   2.180 +								</xsl:for-each>
   2.181 +							</tbody>
   2.182 +						</table>
   2.183 +					</xsl:when>
   2.184 +					<xsl:otherwise><p>no additional formatters are defined (built-in defaults will be used)</p></xsl:otherwise>
   2.185 +				</xsl:choose>
   2.186 +				
   2.187 +			</body>
   2.188 +		</html>
   2.189 +	</xsl:template>
   2.190 +	
   2.191 +	<xsl:template match="c:property">
   2.192 +		<li>
   2.193 +			<xsl:value-of select="@name"/> = <xsl:value-of select="."/>
   2.194 +		</li>
   2.195 +	</xsl:template>
   2.196 +
   2.197 +</xsl:stylesheet>
   2.198 \ No newline at end of file