2 <xsl:stylesheet version="1.0"
 
   3                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 
   5 <xsl:strip-space elements="*" /> 
 
   6 <xsl:output method="xml" omit-xml-declaration="yes" indent="yes" />
 
   9 <!-- Stuff to ignore (ignored because the rules don't do anything) -->
 
  10 <xsl:template match="/top/attributelist" />
 
  11 <xsl:template match="include/attributelist" />
 
  12 <xsl:template match="namespace" />
 
  13 <xsl:template match="typemap" />
 
  14 <xsl:template match="typemapcopy" />
 
  15 <xsl:template match="insert" />
 
  16 <xsl:template match="fragment" />
 
  17 <xsl:template match="constant" />
 
  18 <xsl:template match="import" /> 
 
  21 <!-- Wrap the whole thing in a top level element -->
 
  22 <xsl:template match="/">
 
  23     <xsl:element name="module">
 
  24         <xsl:attribute name="name"><xsl:value-of select="top/attributelist/attribute[@name='module']/@value"/></xsl:attribute>
 
  25         <xsl:apply-templates />
 
  31 <xsl:template match="/top/include/import/module">
 
  32     <xsl:element name="import">
 
  33         <xsl:attribute name="name"><xsl:value-of select="./attributelist/attribute[@name='name']/@value"/></xsl:attribute>
 
  38 <!-- A callable template that outputs the various docstrings for the current node -->
 
  39 <xsl:template name="DoDocstrings">
 
  40     <xsl:if test="./attributelist/attribute[@name='python_autodoc' and @value!='']">
 
  41         <xsl:element name="autodoc"><xsl:value-of select="./attributelist/attribute[@name='python_autodoc']/@value"/></xsl:element>
 
  43     <xsl:if test="./attributelist/attribute[@name='feature_docstring' and @value!='']">
 
  44         <xsl:element name="docstring"><xsl:value-of select="./attributelist/attribute[@name='feature_docstring']/@value"/></xsl:element>
 
  46     <xsl:if test="./attributelist/attribute[@name='feature_refdoc' and @value!='']">
 
  47         <xsl:element name="refdoc"><xsl:value-of select="./attributelist/attribute[@name='feature_refdoc']/@value"/></xsl:element>
 
  52 <!-- A callable template that handles parameter lists -->
 
  53 <xsl:template name="DoParamList">
 
  54     <xsl:if test="attributelist/parmlist">
 
  55         <xsl:element name="paramlist">
 
  56             <xsl:for-each select="attributelist/parmlist/parm">
 
  57                 <xsl:element name="param">
 
  58                     <xsl:attribute name="name"><xsl:value-of select="./attributelist/attribute[@name='name']/@value"/></xsl:attribute>
 
  59                     <xsl:attribute name="type"><xsl:value-of select="./attributelist/attribute[@name='type']/@value"/></xsl:attribute>
 
  60                     <xsl:attribute name="default"><xsl:value-of select="./attributelist/attribute[@name='value']/@value"/></xsl:attribute>
 
  68 <!-- Check for overloaded methods -->
 
  69 <xsl:template name="CheckOverloaded">
 
  71         <xsl:when test="./attributelist/attribute[@name='sym_overloaded']">
 
  72            <xsl:attribute name="overloaded">yes</xsl:attribute>
 
  75            <xsl:attribute name="overloaded">no</xsl:attribute>
 
  82 <!-- A callable template that handles functions, methods, etc. -->
 
  83 <xsl:template name="DoFunction">
 
  84     <xsl:attribute name="name"><xsl:value-of select="./attributelist/attribute[@name='sym_name']/@value"/></xsl:attribute>
 
  85     <!-- <xsl:attribute name="returntype"><xsl:value-of select="./attributelist/attribute[@name='type']/@value"/></xsl:attribute> -->
 
  86     <xsl:call-template name="CheckOverloaded" />
 
  87     <xsl:call-template name="DoDocstrings" />
 
  88     <xsl:call-template name="DoParamList" />            
 
  94 <!-- Create a class element with doc sub elements taken from the attributelist -->
 
  95 <xsl:template match="class">
 
  96     <xsl:element name="class">
 
  98         <xsl:attribute name="name">
 
  99             <xsl:value-of select="./attributelist/attribute[@name='sym_name']/@value"/>
 
 101         <xsl:attribute name="oldname">
 
 102             <xsl:value-of select="./attributelist/attribute[@name='name']/@value"/>
 
 105         <xsl:attribute name="module">
 
 106             <xsl:value-of select="./attributelist/attribute[@name='module']/@value"/>
 
 109         <xsl:call-template name="DoDocstrings" />
 
 110         <xsl:apply-templates />
 
 115 <xsl:template match="base">
 
 116     <xsl:element name="baseclass">
 
 117         <xsl:attribute name="name">
 
 118             <xsl:value-of select="@name"/>
 
 125 <xsl:template match="constructor">
 
 126     <xsl:element name="constructor">
 
 127         <xsl:attribute name="name">
 
 128             <xsl:value-of select="./attributelist/attribute[@name='sym_name']/@value"/>
 
 130         <xsl:call-template name="CheckOverloaded" />
 
 132         <xsl:call-template name="DoDocstrings" />
 
 133         <xsl:call-template name="DoParamList" />
 
 140 <xsl:template match="destructor">
 
 141     <xsl:element name="destructor">
 
 143         <xsl:attribute name="name">
 
 144             <xsl:value-of select="./attributelist/attribute[@name='sym_name']/@value"/>
 
 147         <xsl:call-template name="DoDocstrings" />
 
 148         <xsl:call-template name="DoParamList" />
 
 154 <!-- cdecls: can be functions, methods, properties, etc. -->
 
 155 <xsl:template match="cdecl">
 
 158         <xsl:when test="./attributelist/attribute[@name='view' and @value='memberfunctionHandler']">
 
 159             <xsl:element name="method">
 
 160                 <xsl:call-template name="DoFunction" />
 
 164         <!-- staticmethod -->
 
 165         <xsl:when test="./attributelist/attribute[@name='view' and @value='staticmemberfunctionHandler']">
 
 166             <xsl:element name="staticmethod">
 
 167                 <xsl:call-template name="DoFunction" />
 
 172         <xsl:when test="./attributelist/attribute[@name='view' and @value='variableHandler']">
 
 173             <xsl:element name="property">
 
 174                 <xsl:attribute name="name">
 
 175                     <xsl:value-of select="./attributelist/attribute[@name='sym_name']/@value"/>
 
 177                 <xsl:attribute name="type">
 
 178                     <xsl:value-of select="./attributelist/attribute[@name='type']/@value"/>
 
 181                     <xsl:when test="./attributelist/attribute[@name='feature_immutable']">
 
 182                         <xsl:attribute name="readonly">yes</xsl:attribute>
 
 185                         <xsl:attribute name="readonly">no</xsl:attribute>
 
 188                 <xsl:call-template name="DoDocstrings" />
 
 192         <!-- global function -->
 
 193         <xsl:when test="./attributelist/attribute[@name='view' and @value='globalfunctionHandler']">
 
 194             <xsl:element name="function">
 
 195                 <xsl:attribute name="oldname">
 
 196                     <xsl:value-of select="./attributelist/attribute[@name='name']/@value"/>
 
 198                 <xsl:call-template name="DoFunction" />
 
 206 <!-- %pythoncode directives -->
 
 207 <xsl:template match="insert">
 
 208     <xsl:if test="./attributelist/attribute[@name='section' and @value='python']">
 
 209         <xsl:element name="pythoncode">
 
 210             <xsl:value-of select="./attributelist/attribute[@name='code']/@value"/>