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

Last change on this file since 3179 was 3153, checked in by Nicklas Nordborg, 15 years ago

Added docbook DTD:s and stylesheets

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