home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / xml / gnome / xslt / docbook / html / db2html-funcsynopsis.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2009-03-17  |  6.3 KB  |  195 lines

  1. <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
  2. <!--
  3. This program is free software; you can redistribute it and/or modify it under
  4. the terms of the GNU Lesser General Public License as published by the Free
  5. Software Foundation; either version 2 of the License, or (at your option) any
  6. later version.
  7.  
  8. This program is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  10. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  11. details.
  12.  
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program; see the file COPYING.LGPL.  If not, write to the
  15. Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  16. 02111-1307, USA.
  17. -->
  18.  
  19. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  20.                 xmlns:str="http://exslt.org/strings"
  21.                 xmlns="http://www.w3.org/1999/xhtml"
  22.                 version="1.0">
  23.  
  24. <!--!!==========================================================================
  25. DocBook to HTML - Function Synopses
  26. :Requires: db2html-block db2html-inline
  27.  
  28. REMARK: Describe this module
  29. -->
  30.  
  31.  
  32. <!--@@==========================================================================
  33. db2html.funcsynopsis.style
  34. How to render #{funcsynopsis} elements
  35.  
  36. This parameter controls the indentation style used to render #{funcsynopsis}
  37. elements.  Supported values are #{'KR'} and #{'ANSI'}.  This value can also
  38. be set with the #{db2html.funcsynopsis.style} processing instruction at the
  39. top of the XML document.  The same processing instruction or inside a
  40. #{funcsynopsis} element will override this setting for that synopsis.
  41. -->
  42. <xsl:param name="db2html.funcsynopsis.style">
  43.   <xsl:choose>
  44.     <xsl:when test="/processing-instruction('db2html.funcsynopsis.style')">
  45.       <xsl:value-of select="/processing-instruction('db2html.funcsynopsis.style')"/>
  46.     </xsl:when>
  47.     <xsl:otherwise>
  48.       <xsl:value-of select="'ANSI'"/>
  49.     </xsl:otherwise>
  50.   </xsl:choose>
  51. </xsl:param>
  52.  
  53.  
  54. <!-- == Matched Templates == -->
  55.  
  56. <!-- = funcdef = -->
  57. <xsl:template match="funcdef">
  58.   <xsl:call-template name="db2html.inline"/>
  59. </xsl:template>
  60.  
  61. <!-- = funcparams = -->
  62. <xsl:template match="funcparams">
  63.   <xsl:text>(</xsl:text>
  64.   <xsl:call-template name="db2html.inline"/>
  65.   <xsl:text>)</xsl:text>
  66. </xsl:template>
  67.  
  68. <!-- = funcprototype = -->
  69. <xsl:template match="funcprototype">
  70.   <xsl:variable name="style">
  71.     <xsl:choose>
  72.       <xsl:when test="../processing-instruction('db2html.funcsynopsis.style')">
  73.         <xsl:value-of select="../processing-instruction('db2html.funcsynopsis.style')"/>
  74.       </xsl:when>
  75.       <xsl:otherwise>
  76.         <xsl:value-of select="$db2html.funcsynopsis.style"/>
  77.       </xsl:otherwise>
  78.     </xsl:choose>
  79.   </xsl:variable>
  80.   <xsl:for-each select="funcdef/preceding-sibling::modifier">
  81.     <xsl:apply-templates select="."/>
  82.     <xsl:text> </xsl:text>
  83.   </xsl:for-each>
  84.   <xsl:apply-templates select="funcdef"/>
  85.   <xsl:text> (</xsl:text>
  86.   <xsl:choose>
  87.     <xsl:when test="$style = 'KR'">
  88.       <xsl:for-each select="void | varargs | paramdef">
  89.         <xsl:if test="position() != 1">
  90.           <xsl:text>, </xsl:text>
  91.         </xsl:if>
  92.         <xsl:choose>
  93.           <xsl:when test="self::paramdef">
  94.             <xsl:call-template name="db2html.inline">
  95.               <xsl:with-param name="node" select="."/>
  96.               <xsl:with-param name="children" select="parameter"/>
  97.             </xsl:call-template>
  98.           </xsl:when>
  99.           <xsl:otherwise>
  100.             <xsl:apply-templates select="."/>
  101.           </xsl:otherwise>
  102.         </xsl:choose>
  103.       </xsl:for-each>
  104.       <xsl:text>)</xsl:text>
  105.       <xsl:for-each select="funcdef/following-sibling::modifier">
  106.         <xsl:text> </xsl:text>
  107.         <xsl:apply-templates select="."/>
  108.       </xsl:for-each>
  109.       <xsl:text>;</xsl:text>
  110.       <xsl:for-each select="paramdef">
  111.         <xsl:text>     </xsl:text>
  112.         <xsl:apply-templates select="."/>
  113.         <xsl:text>;</xsl:text>
  114.       </xsl:for-each>
  115.     </xsl:when>
  116.     <!-- ANSI is the default -->
  117.     <xsl:otherwise>
  118.       <xsl:variable name="indent">
  119.         <xsl:call-template name="_db2html.funcsynopsis.pad">
  120.           <xsl:with-param name="nodes" select="funcdef | funcdef/preceding-sibling::modifier"/>
  121.         </xsl:call-template>
  122.         <xsl:value-of select="str:padding(count(funcdef/preceding-sibling::modifier) + 2)"/>
  123.       </xsl:variable>
  124.       <xsl:for-each select="void | varargs | paramdef">
  125.         <xsl:if test="position() != 1">
  126.           <xsl:text>, </xsl:text>
  127.           <xsl:value-of select="$indent"/>
  128.         </xsl:if>
  129.         <xsl:apply-templates select="."/>
  130.       </xsl:for-each>
  131.       <xsl:text>)</xsl:text>
  132.       <xsl:for-each select="funcdef/following-sibling::modifier">
  133.         <xsl:text> </xsl:text>
  134.         <xsl:apply-templates select="."/>
  135.       </xsl:for-each>
  136.       <xsl:text>;</xsl:text>
  137.     </xsl:otherwise>
  138.   </xsl:choose>
  139. </xsl:template>
  140.  
  141. <!-- = funcsynopsis = -->
  142. <xsl:template match="funcsynopsis">
  143.   <xsl:call-template name="db2html.pre">
  144.     <xsl:with-param name="node" select="."/>
  145.     <xsl:with-param name="children" select="*"/>
  146.     <xsl:with-param name="class" select="'synopsis'"/>
  147.   </xsl:call-template>
  148. </xsl:template>
  149.  
  150. <!-- = funcsynopsisinfo = -->
  151. <xsl:template match="funcsynopsisinfo">
  152.   <xsl:call-template name="db2html.pre"/>
  153. </xsl:template>
  154.  
  155. <!-- = initializer = -->
  156. <xsl:template match="initializer">
  157.   <xsl:call-template name="db2html.inline"/>
  158. </xsl:template>
  159.  
  160. <!-- = modifier = -->
  161. <xsl:template match="modifier">
  162.   <xsl:call-template name="db2html.inline"/>
  163. </xsl:template>
  164.  
  165. <!-- = paramdef = -->
  166. <xsl:template match="paramdef">
  167.   <xsl:call-template name="db2html.inline"/>
  168. </xsl:template>
  169.  
  170. <!-- = varargs = -->
  171. <xsl:template match="varargs">
  172.   <xsl:text>...</xsl:text>
  173. </xsl:template>
  174.  
  175. <!-- = void = -->
  176. <xsl:template match="void">
  177.   <xsl:text>void</xsl:text>
  178. </xsl:template>
  179.  
  180.  
  181. <!-- == Utility Templates == -->
  182.  
  183. <!--#* _db2html.funcsynopsis.pad -->
  184. <xsl:template name="_db2html.funcsynopsis.pad">
  185.   <xsl:param name="nodes"/>
  186.   <xsl:value-of select="str:padding(string-length($nodes[1]))"/>
  187.   <xsl:if test="$nodes[position() != 1]">
  188.     <xsl:call-template name="_db2html.funcsynopsis.pad">
  189.       <xsl:with-param name="nodes" select="$nodes[position() != 1]"/>
  190.     </xsl:call-template>
  191.   </xsl:if>
  192. </xsl:template>
  193.  
  194. </xsl:stylesheet>
  195.