******************************************************************** -->
<!-- * Standalone stylesheet for doing "HTML to roff" transformation of a -->
-<!-- * stylesheet; which currently just means that it transforms all -->
-<!-- * <br/> instances into a line break, and all <pre></pre> instances -->
-<!-- * into roff "no fill region" markup -->
+<!-- * stylesheet; which currently means that it transforms: -->
+<!-- * -->
+<!-- * - any <br/> instance into a line break -->
+<!-- * - any <pre></pre> instance into roff "no fill region" markup -->
+<!-- * - HTML table markup for <funcprototype> into tbl(1) markup -->
<!-- ==================================================================== -->
<xsl:element name="xsl:text">.fi </xsl:element>
</xsl:template>
+ <!-- ==================================================================== -->
+
+ <xsl:template match="*[@match = 'funcprototype']/table">
+ <xsl:text> </xsl:text>
+ <xsl:element name="text">.TS </xsl:element>
+ <xsl:text> </xsl:text>
+ <xsl:element name="text">tab(:);</xsl:element>
+ <xsl:text> </xsl:text>
+ <!-- * create the format section for this table by writing one line -->
+ <!-- * for each void|varargs|paramdef instance; the line specifies -->
+ <!-- * 3 cells because the HTML stylesheets generate 3 cells, the 3rd -->
+ <!-- * of which seems to always be empty... -->
+ <xsl:element name="xsl:for-each">
+ <xsl:attribute name="select">(void|varargs|paramdef)</xsl:attribute>
+ <xsl:element name="text"> l l l</xsl:element>
+ </xsl:element>
+ <!-- * close out the format section -->
+ <xsl:element name="text">. </xsl:element>
+ <xsl:copy>
+ <xsl:apply-templates select="@* | node()"/>
+ </xsl:copy>
+ <xsl:element name="text"> .TE </xsl:element>
+ <xsl:element name="xsl:if">
+ <!-- * if this funcprototype has no paramdef children, then we -->
+ <!-- * generate a blank line after it; otherwise, we surpress the -->
+ <!-- * blank line because the table will be followed by another -->
+ <!-- * table this lists the paramdef contents -->
+ <xsl:attribute name="test">not(paramdef)</xsl:attribute>
+ <xsl:element name="text">.sp 1 </xsl:element>
+ </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="*[@match = 'funcprototype']/*[@test = 'paramdef']/table">
+ <!-- * this is the table that lists the paramdef contents -->
+ <xsl:text> </xsl:text>
+ <xsl:element name="text">.TS </xsl:element>
+ <xsl:text> </xsl:text>
+ <xsl:element name="text">tab(:);</xsl:element>
+ <xsl:text> </xsl:text>
+ <!-- * create the format section for this table by writing one line -->
+ <!-- * for each void|varargs|paramdef instance -->
+ <xsl:element name="xsl:for-each">
+ <xsl:attribute name="select">(void|varargs|paramdef)</xsl:attribute>
+ <xsl:element name="text"> l l</xsl:element>
+ </xsl:element>
+ <!-- * close out the format section -->
+ <xsl:element name="text">. </xsl:element>
+ <xsl:copy>
+ <xsl:apply-templates select="@* | node()"/>
+ </xsl:copy>
+ <xsl:element name="text"> .TE </xsl:element>
+ <xsl:element name="text">.sp 1 </xsl:element>
+ </xsl:template>
+
+ <xsl:template match="*[@match = 'funcprototype']//td
+ |*[@match = 'void' or @match = 'varargs']//td[position() > 1]
+ |*[@match = 'paramdef'][contains(@mode,'funcsynopsis')]//td[1]">
+ <xsl:call-template name="format-funcprototype-cell"/>
+ </xsl:template>
+
+ <xsl:template match="*[@match = 'void' or @match = 'varargs']//td[1]
+ |*[@match = 'paramdef'][not(contains(@mode,'funcsynopsis'))]//td[1]">
+ <xsl:call-template name="format-funcprototype-cell">
+ <!-- * we shift the contents of these cells over to the left to -->
+ <!-- * close up space that’s otherwise added by tbl(1) -->
+ <xsl:with-param name="horizontal-adjust">3</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="*[@match = 'paramdef'][not(contains(@mode,'funcsynopsis'))]//td[position() > 1]">
+ <xsl:call-template name="format-funcprototype-cell">
+ <xsl:with-param name="is-closing-cell">1</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="*[@match = 'paramdef'][contains(@mode,'funcsynopsis')]//td[position() > 1]">
+ <xsl:call-template name="format-funcprototype-cell">
+ <!-- * we shift the contents of these cells over to the left to -->
+ <!-- * close up space that’s otherwise added by tbl(1) -->
+ <xsl:with-param name="horizontal-adjust">4</xsl:with-param>
+ <xsl:with-param name="is-closing-cell">1</xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template name="format-funcprototype-cell">
+ <xsl:param name="horizontal-adjust">0</xsl:param>
+ <xsl:param name="is-closing-cell">0</xsl:param>
+ <xsl:element name="text">T{ </xsl:element>
+ <!-- * wrap all content in these cells in no-fill sections, to -->
+ <!-- * prevent groff from adding undesirable line breaks -->
+ <xsl:element name="text">.nf </xsl:element>
+ <xsl:if test="not($horizontal-adjust = 0)">
+ <xsl:element name="text">\h'-<xsl:value-of select="$horizontal-adjust"/>'</xsl:element>
+ </xsl:if>
+ <xsl:copy>
+ <xsl:apply-templates select="@* | node()"/>
+ </xsl:copy>
+ <xsl:element name="text"> .fi</xsl:element>
+ <xsl:choose>
+ <xsl:when test="not($is-closing-cell = 0)">
+ <xsl:element name="text"> T} </xsl:element>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:element name="text"> T}:</xsl:element>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
</xsl:stylesheet>