source: trunk/lib/docbook/preprocess/preprocess.xsl @ 3198

Last change on this file since 3198 was 3198, checked in by Martin Svensson, 15 years ago

Added an ant task and a xsl stylesheet for helptext-import-file generation.

File size: 2.3 KB
Line 
1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
3
4  <xsl:param name="remove.images.width" select="'1'" />
5  <xsl:param name="conditionals" select="''" />
6  <xsl:variable name="normalized" select="concat(' ',normalize-space($conditionals),' ')" />
7
8  <!--
9    Paste an image
10    @element      pasteFigure
11    @attribute    id                The id of this figure will be a concatenation of 'figure:' and the id.
12    If not defined, the file name (without last 4 characters - extension)
13    is used as an id.
14    @attribute    src               Filename (wuthout path) to be used to load the figure.
15    @attribute    width             (optional) image width.
16   
17    @global       remove.images.width If not '0', width attribute is ignored
18  -->
19  <xsl:template match="pasteFigure">
20    <figure>
21      <xsl:attribute name="id">
22        <xsl:if test="@id">
23          <xsl:value-of select="concat('figure:',@id)" />
24        </xsl:if>
25        <xsl:if test="not(@id)">
26          <xsl:value-of
27            select="concat('figure:',substring(@src, 0,string-length(@src)-3))" />
28        </xsl:if>
29      </xsl:attribute>
30      <title>
31        <xsl:apply-templates />
32      </title>
33      <mediaobject>
34        <imageobject>
35          <imagedata fileref="{concat('figures/',@src)}"
36            format="{translate(substring(@src,string-length(@src)-2),'qwertyuioplkjhgfdsazxcvbnm','QWERTYUIOPLKJHGFDSAZXCVBNM')}"
37            align="center">
38            <xsl:if test="$remove.images.width='0' and @width">
39              <xsl:attribute name="width">
40                <xsl:value-of select="@width" />
41              </xsl:attribute>
42            </xsl:if>
43          </imagedata>
44        </imageobject>
45        <textobject>
46          <phrase>
47            <xsl:apply-templates select=".//text()" />
48          </phrase>
49        </textobject>
50      </mediaobject>
51    </figure>
52  </xsl:template>
53
54
55  <!-- Include another file -->
56
57  <xsl:template match="include">
58    <xsl:apply-templates select="document(@file,.)" />
59  </xsl:template>
60
61
62  <!-- Conditional rendering -->
63
64  <xsl:template match="ifdefined">
65    <xsl:if test="contains($normalized,concat(' ',normalize-space(@value),' '))">
66      <xsl:apply-templates />
67    </xsl:if>
68  </xsl:template>
69
70  <!-- Copy all unrecognized elements -->
71
72  <xsl:template match="*|text()|processing-instruction()">
73    <xsl:copy>
74      <xsl:copy-of select="@*" />
75      <xsl:apply-templates />
76    </xsl:copy>
77  </xsl:template>
78
79
80</xsl:stylesheet>
81
82
Note: See TracBrowser for help on using the repository browser.