xml/config.xsl
author František Kučera <franta-hg@frantovo.cz>
Thu, 24 Oct 2019 21:43:08 +0200
branchv_0
changeset 250 aae5009bd0af
parent 249 7655df0622ee
permissions -rw-r--r--
fix license version: GNU GPLv3

<?xml version="1.0" encoding="UTF-8"?>
<!--
SQL-DK
Copyright © 2013 František Kučera (frantovo.cz)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<!--
	This XSLT can be used for viewing config files in a web browser (Firefox, rekonq etc.)
-->

<xsl:stylesheet version="1.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:c="tag:globalcode.info,2018:sqldk/configuration"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fn="http://www.w3.org/2005/xpath-functions"
	xmlns:svg="http://www.w3.org/2000/svg"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	exclude-result-prefixes="fn h p xs">
	<xsl:output
		method="xml"
		indent="yes"
		encoding="UTF-8"
		doctype-public="-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" 
		doctype-system="http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"/>
		
	<xsl:param name="header" select="'SQL-DK configuration'"/>
	
	<xsl:template match="/">
		<html>
			<head>
				<title><xsl:value-of select="$header"/></title>
				<style type="text/css">
					body {
						font-family: sans;
						background-color: #eee;
						color: black;
						padding-left: 20px;
					}
					
					p {
						max-width: 800px;
					}
					
					h1,h2 {
						max-width: 800px;
						border-radius: 8px;
						border: 1px solid #ddd;
						background-color: #e8e8e8;
						padding: 6px;
						text-shadow: 2px 2px 2px #aaa;
					}
					
					h1 {
						font-size: 150%
					}
					
					h2 {
						font-size: 100%;
						font-weight: bold;
					}
					
					table {
						border-collapse:collapse;
						margin-top: 10px;
						margin-bottom: 10px;
					}
					td, th {
						border: 1px solid #ddd;
						padding-top: 4px;
						padding-bottom: 4px;
						padding-left: 6px;
						padding-right: 6px;
						font-weight: normal;
						vertical-align: top;
					}
					thead tr {
						background: #e8e8e8;
						color:black;
					}
					tbody tr:hover {
						background-color: #e9e9e9;
						color:black;
					}
					
					ul {
						margin: 0px;
					}
					
					li {
						padding: 0px;
					}
					
					.notes {
						font-size: 66%;
					}
					.notes p {
						margin-bottom: 0px;
					}
				</style>
			</head>
			<body>
				<h1><xsl:value-of select="$header"/></h1>
				
				<p>
					This file defines per-user configuration of <a href="https://sql-dk.globalcode.info/">SQL-DK</a>
					– an SQL batch client.
				</p>
				
				
				<h2>Database connections</h2>
				
				<p>This databases are configured:</p>
				
				<xsl:choose>
					<xsl:when test="c:configuration/c:database">
						<table>
							<thead>
								<tr>
									<td>name</td>
									<td>username</td>
									<td>url</td>
									<td>JDBC driver</td>
									<td>properties</td>
								</tr>
							</thead>
							<tbody>
								<xsl:for-each select="c:configuration/c:database">
									<tr>
									<td><xsl:value-of select="c:name"/></td>
									<td><xsl:value-of select="c:userName"/></td>
									<td><xsl:value-of select="c:url"/></td>
									<td><xsl:value-of select="c:driver"/></td>
									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
								</tr>
								</xsl:for-each>
							</tbody>
						</table>
					</xsl:when>
					<xsl:otherwise><p>no databases are configured</p></xsl:otherwise>
				</xsl:choose>
				
				<div class="notes">
					<p>Notes:</p>
					<ul>
						<li>passwords are hidden in this output</li>
						<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>
					</ul>
				</div>
				
				
				<h2>Output formatters</h2>
				
				<p>
					Default formatter: 
					<xsl:choose>
						<xsl:when test="c:configuration/c:defaultFormatter"><xsl:value-of select="c:configuration/c:defaultFormatter"/></xsl:when>
						<xsl:otherwise>none (built-in default will be used)</xsl:otherwise>
					</xsl:choose>
				</p>
				
				<xsl:choose>
					<xsl:when test="c:configuration/c:formatter">
						<table>
							<thead>
								<tr>
									<td>name</td>
									<td>class name</td>
									<td>properties</td>
								</tr>
							</thead>
							<tbody>
								<xsl:for-each select="c:configuration/c:formatter">
									<tr>
									<td><xsl:value-of select="c:name"/></td>
									<td><xsl:value-of select="c:class"/></td>
									<td><ul><xsl:apply-templates select="c:property"/></ul></td>
								</tr>
								</xsl:for-each>
							</tbody>
						</table>
					</xsl:when>
					<xsl:otherwise><p>no additional formatters are defined (built-in defaults will be used)</p></xsl:otherwise>
				</xsl:choose>
				
			</body>
		</html>
	</xsl:template>
	
	<xsl:template match="c:property">
		<li>
			<xsl:value-of select="@name"/> = <xsl:value-of select="."/>
		</li>
	</xsl:template>

</xsl:stylesheet>