šablona/makra/diagramy.xsl
author František Kučera <franta-hg@frantovo.cz>
Sat, 07 Jan 2012 12:43:30 +0100
changeset 61 9503eb8377f1
parent 55 7a6267709af8
child 67 89b42acb3593
permissions -rw-r--r--
Licence: informace o licenci v každém souboru.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
<?xml version="1.0" encoding="UTF-8"?>
61
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     2
<!--
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     3
XML Web generátor – program na generování webových stránek
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     4
Copyright © 2012 František Kučera (frantovo.cz)
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     5
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     6
This program is free software: you can redistribute it and/or modify
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     7
it under the terms of the GNU General Public License as published by
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     8
the Free Software Foundation, either version 3 of the License, or
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
     9
(at your option) any later version.
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    10
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    11
This program is distributed in the hope that it will be useful,
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    12
but WITHOUT ANY WARRANTY; without even the implied warranty of
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    14
GNU General Public License for more details.
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    15
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    16
You should have received a copy of the GNU General Public License
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    17
along with this program.  If not, see <http://www.gnu.org/licenses/>.
9503eb8377f1 Licence: informace o licenci v každém souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 55
diff changeset
    18
-->
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
<xsl:stylesheet version="2.0"
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	xmlns="http://www.w3.org/1999/xhtml"
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
	xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	xmlns:j="java:cz.frantovo.xmlWebGenerator.Funkce"
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
	exclude-result-prefixes="m j">
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
    
52
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    26
	<!--
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    27
		Diagramy/grafy
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    28
		**************
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    29
		Můžeme vložit diagram – obrázek.
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    30
		Pro jejich vykreslování se používá Graphviz – diagramy zadáváme v jeho syntaxi.
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    31
		*
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    32
		@orientace „vodorovně“ nebo „svisle“ (výchozí)
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    33
		@nadpis můžeme uvést název diagramu
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    34
		@kompletní „ano“ → předpokládáme kompletní zdroják v GraphViz syntaxi (pak nemá smysl uvádět orientaci). Výchozí je však „ne“ → uživatel zadává jen „vnitřek“ grafu – např. „A -> B; B -> C;“.  
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    35
		@src zadání diagramu načteme ze souboru (potom je výchozí kompletní = 'ne')
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    36
	-->
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    37
	<xsl:template match="m:diagram">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    38
		<xsl:call-template name="vložDiagram">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    39
			<xsl:with-param name="zadání" select="text()"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    40
			<xsl:with-param name="kompletní" select="@kompletní = 'ano'"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    41
		</xsl:call-template>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    42
	</xsl:template>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    43
	
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    44
	<xsl:template match="m:diagram[@src]">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    45
		<xsl:call-template name="vložDiagram">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    46
			<xsl:with-param name="zadání" select="unparsed-text(concat('../', $vstup, @src))"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    47
			<xsl:with-param name="kompletní" select="not(@kompletní) or @kompletní = 'ano'"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    48
		</xsl:call-template>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    49
	</xsl:template>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    50
    
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    51
    <xsl:template name="vložDiagram">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    52
		<xsl:param name="zadání"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    53
		<xsl:param name="kompletní"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    54
		<xsl:variable name="souborDiagramu" select="j:vytvořDiagram($zadání, @orientace = 'vodorovně', $kompletní)"/>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    55
		<xsl:choose>
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
			<xsl:when test="$souborDiagramu">
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
				<div class="diagram">
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
					<a href="{$souborDiagramu}.svg">
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
						<img
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
							src="{$souborDiagramu}.svg" 
55
7a6267709af8 Diagramy #13: lepší alt u obrázku.
František Kučera <franta-hg@frantovo.cz>
parents: 52
diff changeset
    61
							alt="Diagram {(@nadpis, $souborDiagramu)[1]} | pokud nevidíte obrázek, váš prohlížeč stojí za starou bačkoru"
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
							title="{@nadpis} (klikněte pro zobrazení samotného diagramu)"/>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    63
					</a>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    64
					<!-- 
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    65
						TODO: SVG+PNG:
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
						<xsl:variable name="svgDiagramu" select="document(concat($výstup, $souborDiagramu, '.svg'))/svg:svg"/>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
						<object
52
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    68
						data="{$souborDiagramu}.svg"
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    69
						type="image/svg+xml"
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    70
						style="width: {$svgDiagramu/@width}; height: {$svgDiagramu/@height}">
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    71
						<img src="{$souborDiagramu}.png" alt="Diagram {$souborDiagramu}"/>
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    72
						</object>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
					-->
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
					<xsl:if test="@nadpis">
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
						<p class="nadpis"><xsl:value-of select="@nadpis"/></p>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
					</xsl:if>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
				</div>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
			</xsl:when>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
			<xsl:otherwise>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
				<xsl:message terminate="yes">Při vytváření diagramu došlo k chybě.</xsl:message>
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
			</xsl:otherwise>
52
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    82
		</xsl:choose>
a221785fe3ac Diagramy #13: možnost načítání ze souboru.
František Kučera <franta-hg@frantovo.cz>
parents: 51
diff changeset
    83
	</xsl:template>
51
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
df1f942f7b69 Přesun maker do samostatných souborů #8 + automatické generování seznamu maker
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    85
</xsl:stylesheet>