root/šablona/makra/diagramy.xsl @ 61:9503eb8377f1

Revision 61:9503eb8377f1, 3.4 KB (checked in by František Kučera <franta-hg@…>, 12 years ago)

Licence: informace o licenci v každém souboru.

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