]> granicus.if.org Git - docbook-dsssl/commitdiff
rewrote funcprototype. It used to convert all its children to a single
authorMartijn van Beers <lotr@users.sourceforge.net>
Tue, 14 May 2002 18:56:55 +0000 (18:56 +0000)
committerMartijn van Beers <lotr@users.sourceforge.net>
Tue, 14 May 2002 18:56:55 +0000 (18:56 +0000)
string and the split it up again through recursion. Now has a nice
foreach loop for the paramdefs, which seems much cleaner than throwing
everything in a big string before processing it.

contrib/xsl/db2man/synop.xsl

index e657f8fdb198dd5e0726aa7c0385c13002ea45b7..05122660542a0f2dfc94aa105b6e1b897e0ea2e8 100644 (file)
   <xsl:text>&#10;.fi&#10;</xsl:text>
 </xsl:template>
 
-<!-- TODO: Handle K&R-style parameter lists -->
-<xsl:template match="paramdef">
-  <xsl:choose>
-    <xsl:when test="position() > 2">
-      <xsl:text>, </xsl:text>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:text> (</xsl:text>
-    </xsl:otherwise>
-  </xsl:choose>
-  <xsl:apply-templates/>
-</xsl:template>
-
 <xsl:template match="void">
   <xsl:text> (void</xsl:text>
 </xsl:template>
   <xsl:text> (...</xsl:text>
 </xsl:template>
 
-<xsl:template name="wrap-fn">
-  <xsl:param name="indent" select="''"/>
-  <xsl:param name="text" select="''"/>
-  <xsl:variable name="total" select="string-length($text)"/>
-  <xsl:variable name="param" select="substring-before($text,',')"/>
-  <xsl:choose>
-    <xsl:when test="$param=''">
-      <xsl:value-of select="$text"/>
-    </xsl:when>
-    <xsl:otherwise>
-      <xsl:value-of select="$param"/>
-      <xsl:text>,&#10;</xsl:text>
-      <xsl:value-of select="$indent"/>
-      <xsl:variable name="done" select="string-length($param)"/>
-      <xsl:variable name="remaining" select="$total - $done + 1"/>
-      <xsl:call-template name="wrap-fn">
-        <xsl:with-param name="indent" select="$indent"/>
-        <xsl:with-param name="text"
-                        select="substring($text,2+$done,$remaining)"/>
-      </xsl:call-template>
-    </xsl:otherwise>
-  </xsl:choose>
-</xsl:template>
-
 <xsl:template match="funcsynopsisinfo">
   <xsl:text>&#10;</xsl:text>
   <xsl:apply-templates/>
   <xsl:text>.fi&#10;</xsl:text>
 </xsl:template>
 
+<!-- TODO: Handle K&R-style parameter lists
+           Comment that used to go with the paramdef template, which
+          is now obsolete and thus deleted
+-->
+
 <xsl:template match="funcprototype">
-  <xsl:variable name="fnprototype">
-    <xsl:apply-templates/>
+  <xsl:variable name="funcprototype">
+    <xsl:apply-templates select="funcdef"/>
   </xsl:variable>
-  <xsl:variable name="funcprototype" select="normalize-space($fnprototype)"/>
-  <xsl:variable name="fn"
-       select="substring-before($funcprototype,'(')"/>
-  <xsl:variable name="indent"
-                select="translate($fn,$fn,'                               ')"/>
   <xsl:text>.sp&#10;</xsl:text>
-  <xsl:value-of select="substring-before($funcprototype,'(')"/>
-  <xsl:text>(</xsl:text>
-  <xsl:call-template name="wrap-fn">
-    <xsl:with-param name="indent"
-    select="substring($indent,1,string-length($indent) - 6)"/>
-    <xsl:with-param name="text"
-                    select="substring-after($funcprototype,'(')"/>
-  </xsl:call-template>
-  <xsl:text>);&#10;</xsl:text>
+  <xsl:value-of select="normalize-space ($funcprototype)"/>
+  <xsl:text> (</xsl:text>
+  <xsl:for-each select="paramdef">
+    <xsl:variable name="param">
+      <xsl:apply-templates select="." />
+    </xsl:variable>
+    <xsl:value-of select="normalize-space ($param)" />
+    <xsl:choose>
+      <xsl:when test="following-sibling::paramdef">
+       <xsl:text>,&#10;</xsl:text>
+      </xsl:when>
+      <xsl:otherwise>
+       <xsl:text>);&#10;.RE&#10;</xsl:text>
+      </xsl:otherwise>
+    </xsl:choose>
+    <xsl:if test="not (preceding-sibling::paramdef)">
+      <xsl:text>.RS </xsl:text>
+      <xsl:value-of
+       select="string-length(normalize-space ($funcprototype)) - 4" />
+      <xsl:text>&#10;</xsl:text>
+    </xsl:if>
+  </xsl:for-each>
 </xsl:template>
 
 </xsl:stylesheet>