templates/ssm.xhtml.xsl
author František Kučera <franta-hg@frantovo.cz>
Fri, 10 May 2024 00:10:08 +0200
branchv_0
changeset 82 a11239f9f9e7
parent 81 47717a4ed4bb
permissions -rw-r--r--
EPUB: move Preamble to the same level as other chapters

<?xml version="1.0" encoding="UTF-8"?>
<!--
	Sane software manifesto helper tools
	Copyright © 2019-2024 František Kučera (Frantovo.cz, GlobalCode.info)

	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.

	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 <https://www.gnu.org/licenses/>.
-->
<xsl:stylesheet
	version="1.0"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://www.w3.org/1999/xhtml"
	xmlns:m="tag:globalcode.info,2019:sane-software/manifesto"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fn="http://www.w3.org/2005/xpath-functions"
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	exclude-result-prefixes="fn h m xs">

	<xsl:import href="common.xsl"/>

	<xsl:param name="versionTag"/>
	<xsl:param name="versionDistance"/>
	<xsl:param name="versionHash"/>
	<xsl:param name="versionChangedFiles"/>

	<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:template match="/m:manifesto">
		<html>
			<head>
				<title>
					<xsl:value-of select="m:title"/>
				</title>
				<link href="style.css" 	type="text/css" rel="StyleSheet"/>
			</head>
			<body>
				<div id="content">
					<h1>
						<xsl:value-of select="m:title"/>
					</h1>

					<xsl:call-template name="versionParagraph"/>

					<p>
						<xsl:value-of select="m:preamble"/>
					</p>

					<xsl:apply-templates select="m:chapter"/>

					<xsl:call-template name="footer"/>

				</div>
			</body>
		</html>
	</xsl:template>

	<xsl:template name="versionParagraph">
		<p style="text-align: center">
			<xsl:call-template name="version">
				<xsl:with-param name="tag" select="$versionTag"/>
				<xsl:with-param name="distance" select="$versionDistance"/>
				<xsl:with-param name="hash" select="$versionHash"/>
				<xsl:with-param name="changedFiles" select="$versionChangedFiles"/>
			</xsl:call-template>
		</p>
	</xsl:template>

	<xsl:template name="footer">
		<xsl:param name="otherFormatsURL"/>
		<hr/>
		<p class="footer">
			<a href="{/m:manifesto/m:url}">
				<xsl:value-of select="/m:manifesto/m:title"/>
			</a>
			(<a href="https://hg.globalcode.info/sane-software/sane-software-manifesto/">sources</a>)
			other formats:
			<a href="{normalize-space($otherFormatsURL)}ssm.en.pdf">PDF</a>,
			<a href="{normalize-space($otherFormatsURL)}ssm.en.txt">TXT</a>,
			<a href="{normalize-space($otherFormatsURL)}ssm.en.epub">EPUB</a>
			<br/>
			Copyright © <xsl:value-of select="/m:manifesto/m:license/m:year"/>
			<xsl:text> </xsl:text>
			<xsl:value-of select="/m:manifesto/m:author"/>
			<br/>
			<xsl:value-of select="/m:manifesto/m:license/m:prefix"/>
			<a href="{/m:manifesto/m:license/m:url}">
				<xsl:value-of select="/m:manifesto/m:license/m:name"/>
			</a>
			<xsl:value-of select="/m:manifesto/m:license/m:suffix"/>
		</p>
	</xsl:template>


	<xsl:template match="m:chapter">
		<div id="{m:id}" class="chapter">
			<h2>
				<xsl:value-of select="m:name"/>
				<xsl:text> </xsl:text>
				<a href="#{m:id}" class="anchor">§</a>
			</h2>
			<ul>
				<xsl:apply-templates select="m:item"/>
			</ul>
		</div>
	</xsl:template>


	<xsl:template match="m:item">
		<li id="{m:id}" class="{m:type}">
			<xsl:apply-templates select="m:text"/>
			<xsl:text> </xsl:text>
			<a href="#{m:id}" class="anchor">§</a>
			<xsl:if test="m:item">
				<ul>
					<xsl:apply-templates select="m:item"/>
				</ul>
			</xsl:if>
		</li>
	</xsl:template>

	<xsl:template match="m:text">
		<xsl:apply-templates/>
		<xsl:text>&#10;</xsl:text>
	</xsl:template>

</xsl:stylesheet>