mediaobjectco.xsl coverage = 1/159 ( 0.63%)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>

<!--############################################################################
    XSLT Stylesheet DocBook -> LaTeX 
    ############################################################################ -->

<xsl:param name="imageobjectco.hide" select="0"/>

<xsl:template match="mediaobjectco">
  <xsl:if test="not(parent::figure)">
    <xsl:text>&#10;</xsl:text>
    <xsl:text>\begin{minipage}{\linewidth}&#10;</xsl:text>
    <xsl:call-template name="figure.begin"/>
  </xsl:if>
  <!-- Forget the textobject -->
  <xsl:apply-templates select="imageobjectco[1]"/>
  <xsl:if test="not(parent::figure)">
    <xsl:call-template name="figure.end"/>
    <xsl:text>\end{minipage}&#10;</xsl:text>
    <xsl:text>&#10;</xsl:text>
  </xsl:if>
</xsl:template>

<xsl:template match="imageobjectco">
  <!-- Do as if we could have several imageobjects (DocBook 5) -->
  <xsl:variable name="idx">
    <xsl:call-template name="mediaobject.select.idx"/>
  </xsl:variable>
  <xsl:apply-templates select="imageobject[position()=$idx]"/>
  <xsl:apply-templates select="calloutlist"/>
</xsl:template>

<xsl:template match="imageobjectco" mode="graphic.begin">
  <xsl:text>\begin{overpic}</xsl:text>
</xsl:template>

<xsl:template match="imageobjectco" mode="graphic.end">
  <xsl:text>&#10;\picfactoreval</xsl:text>
  <xsl:apply-templates select="areaspec//area" mode="graphic"/>
  <xsl:text>\end{overpic}</xsl:text>
</xsl:template>

<!-- Cut a coord of the form "x,y" and gives x or y -->
<xsl:template name="coord.get">
  <xsl:param name="axe"/>
  <xsl:param name="def"/>
  <xsl:param name="xy"/>

  <xsl:choose>
  <xsl:when test="contains($xy, ',')">
    <xsl:choose>
    <xsl:when test="$axe='x'">
      <xsl:value-of select="substring-before($xy, ',')"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="substring-after($xy, ',')"/>
    </xsl:otherwise>
    </xsl:choose>
  </xsl:when>
  <xsl:otherwise>
    <xsl:if test="$axe=$def">
      <xsl:value-of select="$xy"/>
    </xsl:if>
  </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Check the validity or a coordinate -->
<xsl:template name="coord.check">
  <xsl:param name="x"/>
  <xsl:if test="$x!=''">
    <xsl:choose>
    <xsl:when test="string(number($x))='NaN'">
      <xsl:message>
        <xsl:text>*** Error: </xsl:text>
        <xsl:value-of select="$x"/>
        <xsl:text>: invalid calspair coordinate</xsl:text>
      </xsl:message>
      <xsl:value-of select='1'/>
    </xsl:when>
    <xsl:when test="number($x)&gt;10000">
      <xsl:message>
        <xsl:text>*** Error: </xsl:text>
        <xsl:value-of select="$x"/>
        <xsl:text>: calspair out of range</xsl:text>
      </xsl:message>
      <xsl:value-of select='1'/>
    </xsl:when>
    </xsl:choose>
  </xsl:if>
</xsl:template>

<!-- Put the callout mark on the graphic, according to the caspair
     coordinates -->

<xsl:template match="area" mode="graphic">
  <xsl:variable name="x1y1">
    <xsl:value-of select="substring-before(@coords, ' ')"/>
  </xsl:variable>
  <xsl:variable name="x2y2">
    <xsl:value-of select="substring-after(@coords, ' ')"/>
  </xsl:variable>

  <!-- coordinates -->
  <xsl:variable name="x1">
    <xsl:call-template name="coord.get">
      <xsl:with-param name="xy" select="$x1y1"/>
      <xsl:with-param name="axe" select="'x'"/>
      <xsl:with-param name="def" select="'x'"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y1">
    <xsl:call-template name="coord.get">
      <xsl:with-param name="xy" select="$x1y1"/>
      <xsl:with-param name="axe" select="'y'"/>
      <xsl:with-param name="def" select="'x'"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="x2">
    <xsl:call-template name="coord.get">
      <xsl:with-param name="xy" select="$x2y2"/>
      <xsl:with-param name="axe" select="'x'"/>
      <xsl:with-param name="def" select="'y'"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:variable name="y2">
    <xsl:call-template name="coord.get">
      <xsl:with-param name="xy" select="$x2y2"/>
      <xsl:with-param name="axe" select="'y'"/>
      <xsl:with-param name="def" select="'y'"/>
    </xsl:call-template>
  </xsl:variable>

  <!-- consistency check of @coords -->
  <xsl:variable name="coord.error">
    <xsl:if test="$x1y1='' or $x2y2=''">
      <xsl:message>
        <xsl:text>*** Error: </xsl:text>
        <xsl:value-of select="@coords"/>
        <xsl:text>: invalid calspair</xsl:text>
      </xsl:message>
      <xsl:value-of select="'1'"/>
    </xsl:if>
    <xsl:call-template name="coord.check">
      <xsl:with-param name="x" select="$x1"/>
    </xsl:call-template>
    <xsl:call-template name="coord.check">
      <xsl:with-param name="x" select="$y1"/>
    </xsl:call-template>
    <xsl:call-template name="coord.check">
      <xsl:with-param name="x" select="$x2"/>
    </xsl:call-template>
    <xsl:call-template name="coord.check">
      <xsl:with-param name="x" select="$y2"/>
    </xsl:call-template>
  </xsl:variable>

  <xsl:if test="$coord.error=''">
    <xsl:text>\calspair{</xsl:text>

    <!-- choose horizontal coordinate -->
    <xsl:choose>
      <xsl:when test="$x1 != '' and $x2 != ''">
        <xsl:value-of select="(number($x1)+number($x2)) div 200"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="number(concat($x1, $x2)) div 100"/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>}{</xsl:text>
    <!-- choose vertical coordinate -->
    <xsl:choose>
      <xsl:when test="$y1 != '' and $y2 != ''">
        <xsl:value-of select="(number($y1)+number($y2)) div 200"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="number(concat($y1, $y2)) div 100"/>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text>}{</xsl:text>
    <!-- callout markup in the image. No tex escape sequence needed here -->
    <xsl:apply-templates select="." mode="latex.programlisting">
      <xsl:with-param name="co-tagin" select="''"/>
      <xsl:with-param name="co-tagout" select="''"/>
      <xsl:with-param name="co-hide" select="$imageobjectco.hide"/>
    </xsl:apply-templates>
    <xsl:text>}&#10;</xsl:text>
  </xsl:if>
</xsl:template>
  
</xsl:stylesheet>