root/šablona/makra/diagramy.xsl @ 76:c7746d95283d

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

Rozdělení knihovny funkcí podle maker, ve kterých se funkce používají. #8

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.makra.Diagram"
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="m:načti-textový-soubor(@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(
55                                                                                                                        $zadání,
56                                                                                                                        @orientace = 'vodorovně',
57                                                                                                                        $kompletní,
58                                                                                                                        tokenize(base-uri(), '/')[last()],
59                                                                                                                        @src
60                                                                                                                        )"/>
61                <xsl:choose>
62                        <xsl:when test="$souborDiagramu">
63                                <div class="diagram">
64                                        <a href="{encode-for-uri($souborDiagramu)}.svg">
65                                                <img
66                                                        src="{encode-for-uri($souborDiagramu)}.svg" 
67                                                        alt="Diagram {(@nadpis, $souborDiagramu)[1]} | pokud nevidíte obrázek, váš prohlížeč stojí za starou bačkoru"
68                                                        title="{@nadpis} (klikněte pro zobrazení samotného diagramu)"/>
69                                        </a>
70                                        <!--
71                                                TODO: SVG+PNG:
72                                                <xsl:variable name="svgDiagramu" select="document(concat($výstup, $souborDiagramu, '.svg'))/svg:svg"/>
73                                                <object
74                                                data="{$souborDiagramu}.svg"
75                                                type="image/svg+xml"
76                                                style="width: {$svgDiagramu/@width}; height: {$svgDiagramu/@height}">
77                                                <img src="{$souborDiagramu}.png" alt="Diagram {$souborDiagramu}"/>
78                                                </object>
79                                        -->
80                                        <xsl:if test="@nadpis">
81                                                <p class="nadpis"><xsl:value-of select="@nadpis"/></p>
82                                        </xsl:if>
83                                </div>
84                        </xsl:when>
85                        <xsl:otherwise>
86                                <xsl:message terminate="yes">Při vytváření diagramu došlo k chybě.</xsl:message>
87                        </xsl:otherwise>
88                </xsl:choose>
89        </xsl:template>
90
91</xsl:stylesheet>
Note: See TracBrowser for help on using the browser.