code: def toxml(self):
          
  
          chxmlstr = ''
  
          for state_variable in self.state_variables:
              chxmlstr += state_variable.toxml()
  
          for derived_variable in self.derived_variables:
              chxmlstr += derived_variable.toxml()
              
          for conditional_derived_variable in self.conditional_derived_variables:
              chxmlstr += conditional_derived_variable.toxml()
  
          for time_derivative in self.time_derivatives:
              chxmlstr += time_derivative.toxml()
  
          for event_handler in self.event_handlers:
              chxmlstr += event_handler.toxml()
  
          for kinetic_scheme in self.kinetic_schemes:
              chxmlstr += kinetic_scheme.toxml()
  
          if isinstance(self, Dynamics):
              for regime in self.regimes:
                  chxmlstr += regime.toxml()
  
          if isinstance(self, Dynamics):
              xmlprefix = 'Dynamics'
              xmlsuffix = 'Dynamics'
              xmlempty = ''
          else:
              xmlprefix = 'Regime name="{0}"'.format(self.name) +\
                (' initial="true"' if self.initial else '')
              xmlsuffix = 'Regime'
              xmlempty = '<{0}/>',format(xmlprefix)
  
          if chxmlstr:
              xmlstr = '<{0}>'.format(xmlprefix) + chxmlstr + '</{0}>'.format(xmlsuffix)
          else:
              xmlstr = xmlempty
  
          return xmlstr
docs: Exports this object into a LEMS XML object