| 1 |
<?xml version='1.0'?> |
| 2 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'> |
| 3 |
|
| 4 |
<!--############################################################################ |
| 5 |
XSLT Stylesheet DocBook -> LaTeX |
| 6 |
############################################################################ --> |
| 7 |
|
| 8 |
<xsl:param name="imageobjectco.hide" select="0"/> |
| 9 |
|
| 10 |
<xsl:template match="mediaobjectco"> |
| 11 |
<xsl:if test="not(parent::figure)"> |
| 12 |
<xsl:text> </xsl:text> |
| 13 |
<xsl:text>\begin{minipage}{\linewidth} </xsl:text> |
| 14 |
<xsl:call-template name="figure.begin"/> |
| 15 |
</xsl:if> |
| 16 |
<!-- Forget the textobject --> |
| 17 |
<xsl:apply-templates select="imageobjectco[1]"/> |
| 18 |
<xsl:if test="not(parent::figure)"> |
| 19 |
<xsl:call-template name="figure.end"/> |
| 20 |
<xsl:text>\end{minipage} </xsl:text> |
| 21 |
<xsl:text> </xsl:text> |
| 22 |
</xsl:if> |
| 23 |
</xsl:template> |
| 24 |
|
| 25 |
<xsl:template match="imageobjectco"> |
| 26 |
<!-- Do as if we could have several imageobjects (DocBook 5) --> |
| 27 |
<xsl:variable name="idx"> |
| 28 |
<xsl:call-template name="mediaobject.select.idx"/> |
| 29 |
</xsl:variable> |
| 30 |
<xsl:apply-templates select="imageobject[position()=$idx]"/> |
| 31 |
<xsl:apply-templates select="calloutlist"/> |
| 32 |
</xsl:template> |
| 33 |
|
| 34 |
<xsl:template match="imageobjectco" mode="graphic.begin"> |
| 35 |
<xsl:text>\begin{overpic}</xsl:text> |
| 36 |
</xsl:template> |
| 37 |
|
| 38 |
<xsl:template match="imageobjectco" mode="graphic.end"> |
| 39 |
<xsl:text> \picfactoreval</xsl:text> |
| 40 |
<xsl:apply-templates select="areaspec//area" mode="graphic"/> |
| 41 |
<xsl:text>\end{overpic}</xsl:text> |
| 42 |
</xsl:template> |
| 43 |
|
| 44 |
<!-- Cut a coord of the form "x,y" and gives x or y --> |
| 45 |
<xsl:template name="coord.get"> |
| 46 |
<xsl:param name="axe"/> |
| 47 |
<xsl:param name="def"/> |
| 48 |
<xsl:param name="xy"/> |
| 49 |
|
| 50 |
<xsl:choose> |
| 51 |
<xsl:when test="contains($xy, ',')"> |
| 52 |
<xsl:choose> |
| 53 |
<xsl:when test="$axe='x'"> |
| 54 |
<xsl:value-of select="substring-before($xy, ',')"/> |
| 55 |
</xsl:when> |
| 56 |
<xsl:otherwise> |
| 57 |
<xsl:value-of select="substring-after($xy, ',')"/> |
| 58 |
</xsl:otherwise> |
| 59 |
</xsl:choose> |
| 60 |
</xsl:when> |
| 61 |
<xsl:otherwise> |
| 62 |
<xsl:if test="$axe=$def"> |
| 63 |
<xsl:value-of select="$xy"/> |
| 64 |
</xsl:if> |
| 65 |
</xsl:otherwise> |
| 66 |
</xsl:choose> |
| 67 |
</xsl:template> |
| 68 |
|
| 69 |
<!-- Check the validity or a coordinate --> |
| 70 |
<xsl:template name="coord.check"> |
| 71 |
<xsl:param name="x"/> |
| 72 |
<xsl:if test="$x!=''"> |
| 73 |
<xsl:choose> |
| 74 |
<xsl:when test="string(number($x))='NaN'"> |
| 75 |
<xsl:message> |
| 76 |
<xsl:text>*** Error: </xsl:text> |
| 77 |
<xsl:value-of select="$x"/> |
| 78 |
<xsl:text>: invalid calspair coordinate</xsl:text> |
| 79 |
</xsl:message> |
| 80 |
<xsl:value-of select='1'/> |
| 81 |
</xsl:when> |
| 82 |
<xsl:when test="number($x)>10000"> |
| 83 |
<xsl:message> |
| 84 |
<xsl:text>*** Error: </xsl:text> |
| 85 |
<xsl:value-of select="$x"/> |
| 86 |
<xsl:text>: calspair out of range</xsl:text> |
| 87 |
</xsl:message> |
| 88 |
<xsl:value-of select='1'/> |
| 89 |
</xsl:when> |
| 90 |
</xsl:choose> |
| 91 |
</xsl:if> |
| 92 |
</xsl:template> |
| 93 |
|
| 94 |
<!-- Put the callout mark on the graphic, according to the caspair |
| 95 |
coordinates --> |
| 96 |
|
| 97 |
<xsl:template match="area" mode="graphic"> |
| 98 |
<xsl:variable name="x1y1"> |
| 99 |
<xsl:value-of select="substring-before(@coords, ' ')"/> |
| 100 |
</xsl:variable> |
| 101 |
<xsl:variable name="x2y2"> |
| 102 |
<xsl:value-of select="substring-after(@coords, ' ')"/> |
| 103 |
</xsl:variable> |
| 104 |
|
| 105 |
<!-- coordinates --> |
| 106 |
<xsl:variable name="x1"> |
| 107 |
<xsl:call-template name="coord.get"> |
| 108 |
<xsl:with-param name="xy" select="$x1y1"/> |
| 109 |
<xsl:with-param name="axe" select="'x'"/> |
| 110 |
<xsl:with-param name="def" select="'x'"/> |
| 111 |
</xsl:call-template> |
| 112 |
</xsl:variable> |
| 113 |
<xsl:variable name="y1"> |
| 114 |
<xsl:call-template name="coord.get"> |
| 115 |
<xsl:with-param name="xy" select="$x1y1"/> |
| 116 |
<xsl:with-param name="axe" select="'y'"/> |
| 117 |
<xsl:with-param name="def" select="'x'"/> |
| 118 |
</xsl:call-template> |
| 119 |
</xsl:variable> |
| 120 |
<xsl:variable name="x2"> |
| 121 |
<xsl:call-template name="coord.get"> |
| 122 |
<xsl:with-param name="xy" select="$x2y2"/> |
| 123 |
<xsl:with-param name="axe" select="'x'"/> |
| 124 |
<xsl:with-param name="def" select="'y'"/> |
| 125 |
</xsl:call-template> |
| 126 |
</xsl:variable> |
| 127 |
<xsl:variable name="y2"> |
| 128 |
<xsl:call-template name="coord.get"> |
| 129 |
<xsl:with-param name="xy" select="$x2y2"/> |
| 130 |
<xsl:with-param name="axe" select="'y'"/> |
| 131 |
<xsl:with-param name="def" select="'y'"/> |
| 132 |
</xsl:call-template> |
| 133 |
</xsl:variable> |
| 134 |
|
| 135 |
<!-- consistency check of @coords --> |
| 136 |
<xsl:variable name="coord.error"> |
| 137 |
<xsl:if test="$x1y1='' or $x2y2=''"> |
| 138 |
<xsl:message> |
| 139 |
<xsl:text>*** Error: </xsl:text> |
| 140 |
<xsl:value-of select="@coords"/> |
| 141 |
<xsl:text>: invalid calspair</xsl:text> |
| 142 |
</xsl:message> |
| 143 |
<xsl:value-of select="'1'"/> |
| 144 |
</xsl:if> |
| 145 |
<xsl:call-template name="coord.check"> |
| 146 |
<xsl:with-param name="x" select="$x1"/> |
| 147 |
</xsl:call-template> |
| 148 |
<xsl:call-template name="coord.check"> |
| 149 |
<xsl:with-param name="x" select="$y1"/> |
| 150 |
</xsl:call-template> |
| 151 |
<xsl:call-template name="coord.check"> |
| 152 |
<xsl:with-param name="x" select="$x2"/> |
| 153 |
</xsl:call-template> |
| 154 |
<xsl:call-template name="coord.check"> |
| 155 |
<xsl:with-param name="x" select="$y2"/> |
| 156 |
</xsl:call-template> |
| 157 |
</xsl:variable> |
| 158 |
|
| 159 |
<xsl:if test="$coord.error=''"> |
| 160 |
<xsl:text>\calspair{</xsl:text> |
| 161 |
|
| 162 |
<!-- choose horizontal coordinate --> |
| 163 |
<xsl:choose> |
| 164 |
<xsl:when test="$x1 != '' and $x2 != ''"> |
| 165 |
<xsl:value-of select="(number($x1)+number($x2)) div 200"/> |
| 166 |
</xsl:when> |
| 167 |
<xsl:otherwise> |
| 168 |
<xsl:value-of select="number(concat($x1, $x2)) div 100"/> |
| 169 |
</xsl:otherwise> |
| 170 |
</xsl:choose> |
| 171 |
<xsl:text>}{</xsl:text> |
| 172 |
<!-- choose vertical coordinate --> |
| 173 |
<xsl:choose> |
| 174 |
<xsl:when test="$y1 != '' and $y2 != ''"> |
| 175 |
<xsl:value-of select="(number($y1)+number($y2)) div 200"/> |
| 176 |
</xsl:when> |
| 177 |
<xsl:otherwise> |
| 178 |
<xsl:value-of select="number(concat($y1, $y2)) div 100"/> |
| 179 |
</xsl:otherwise> |
| 180 |
</xsl:choose> |
| 181 |
<xsl:text>}{</xsl:text> |
| 182 |
<!-- callout markup in the image. No tex escape sequence needed here --> |
| 183 |
<xsl:apply-templates select="." mode="latex.programlisting"> |
| 184 |
<xsl:with-param name="co-tagin" select="''"/> |
| 185 |
<xsl:with-param name="co-tagout" select="''"/> |
| 186 |
<xsl:with-param name="co-hide" select="$imageobjectco.hide"/> |
| 187 |
</xsl:apply-templates> |
| 188 |
<xsl:text>} </xsl:text> |
| 189 |
</xsl:if> |
| 190 |
</xsl:template> |
| 191 |
|
| 192 |
</xsl:stylesheet> |