root/šablona/makra/diagramy.xsl @ 136:d5feb9d8ebc3

Revision 136:d5feb9d8ebc3, 3.6 KB (checked in by František Kučera <franta-hg@…>, 4 years ago)

fix license version: GNU GPLv3

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3XML Web generátor – program na generování webových stránek
4Copyright © 2012 František Kučera (frantovo.cz)
5
6This program is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, version 3 of the License.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program.  If not, see <http://www.gnu.org/licenses/>.
17-->
18<xsl:stylesheet version="2.0"
19        xmlns="http://www.w3.org/1999/xhtml"
20        xmlns:m="https://trac.frantovo.cz/xml-web-generator/wiki/xmlns/makro"
21        xmlns:j="java:cz.frantovo.xmlWebGenerator.makra.Diagram"
22        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
23        exclude-result-prefixes="m j">
24
25        <!--
26                Diagramy/grafy
27                **************
28                Můžeme vložit diagram – obrázek.
29                Pro jejich vykreslování se používá Graphviz – diagramy zadáváme v jeho syntaxi.
30                *
31                @orientace „vodorovně“ nebo „svisle“ (výchozí)
32                @nadpis můžeme uvést název diagramu
33                @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;“. 
34                @src zadání diagramu načteme ze souboru (potom je výchozí kompletní = 'ne')
35        -->
36        <xsl:template match="m:diagram">
37                <xsl:variable name="zadání">
38                        <xsl:apply-templates select="*|text()"/>
39                </xsl:variable>
40                <xsl:call-template name="vložDiagram">
41                        <xsl:with-param name="zadání" select="$zadání"/>
42                        <xsl:with-param name="kompletní" select="@kompletní = 'ano'"/>
43                </xsl:call-template>
44        </xsl:template>
45       
46        <xsl:template match="m:diagram[@src]">
47                <xsl:call-template name="vložDiagram">
48                        <xsl:with-param name="zadání" select="m:načti-textový-soubor(@src)"/>
49                        <xsl:with-param name="kompletní" select="not(@kompletní) or @kompletní = 'ano'"/>
50                </xsl:call-template>
51        </xsl:template>
52
53        <xsl:template name="vložDiagram">
54                <xsl:param name="zadání"/>
55                <xsl:param name="kompletní"/>
56                <xsl:variable name="souborDiagramu" select="j:vytvořDiagram(
57                                                                                                                        $zadání,
58                                                                                                                        @orientace = 'vodorovně',
59                                                                                                                        $kompletní,
60                                                                                                                        tokenize(base-uri(), '/')[last()],
61                                                                                                                        @src
62                                                                                                                        )"/>
63                <xsl:choose>
64                        <xsl:when test="$souborDiagramu">
65                                <div class="diagram">
66                                        <a href="{encode-for-uri($souborDiagramu)}.svg">
67                                                <img
68                                                        src="{encode-for-uri($souborDiagramu)}.svg" 
69                                                        alt="Diagram {(@nadpis, $souborDiagramu)[1]} | pokud nevidíte obrázek, váš prohlížeč stojí za starou bačkoru"
70                                                        title="{@nadpis} (klikněte pro zobrazení samotného diagramu)"/>
71                                        </a>
72                                        <!--
73                                                TODO: SVG+PNG:
74                                                <xsl:variable name="svgDiagramu" select="document(concat($výstup, $souborDiagramu, '.svg'))/svg:svg"/>
75                                                <object
76                                                data="{$souborDiagramu}.svg"
77                                                type="image/svg+xml"
78                                                style="width: {$svgDiagramu/@width}; height: {$svgDiagramu/@height}">
79                                                <img src="{$souborDiagramu}.png" alt="Diagram {$souborDiagramu}"/>
80                                                </object>
81                                        -->
82                                        <xsl:if test="@nadpis">
83                                                <p class="nadpis"><xsl:value-of select="@nadpis"/></p>
84                                        </xsl:if>
85                                </div>
86                        </xsl:when>
87                        <xsl:otherwise>
88                                <xsl:message terminate="yes">Při vytváření diagramu došlo k chybě.</xsl:message>
89                        </xsl:otherwise>
90                </xsl:choose>
91        </xsl:template>
92
93</xsl:stylesheet>
94
Note: See TracBrowser for help on using the browser.