Exports this object into a LEMS XML object

def toxml(self):
        """
        Exports this object into a LEMS XML object
        """

        xmlstr = '<ComponentType name="{0}"'.format(self.name) +\
          (' extends="{0}"'.format(self.extends) if self.extends else '') +\
          (' description="{0}"'.format(self.description) if self.description else '')

        chxmlstr = ''

        for property in self.properties:
            chxmlstr += property.toxml()

        for parameter in self.parameters:
            chxmlstr += parameter.toxml()
            
        for derived_parameter in self.derived_parameters:
            chxmlstr += derived_parameter.toxml()
            
        for index_parameter in self.index_parameters:
            chxmlstr += index_parameter.toxml()

        for constant in self.constants:
            chxmlstr += constant.toxml()
            
        childxml = ''
        childrenxml = ''
        
        for children in self.children:
            if children.multiple:
                childrenxml += children.toxml()
            else:
                childxml += children.toxml()
            
        chxmlstr += childxml
        chxmlstr += childrenxml
            
        for link in self.links:
            chxmlstr += link.toxml()
            
        for component_reference in self.component_references:
            chxmlstr += component_reference.toxml()
            
        for attachment in self.attachments:
            chxmlstr += attachment.toxml()
            
        for event_port in self.event_ports:
            chxmlstr += event_port.toxml()
            
        for exposure in self.exposures:
            chxmlstr += exposure.toxml()
            
        for requirement in self.requirements:
            chxmlstr += requirement.toxml()
            
        for component_requirement in self.component_requirements:
            chxmlstr += component_requirement.toxml()
            
        for instance_requirement in self.instance_requirements:
            chxmlstr += instance_requirement.toxml()
            
        for path in self.paths:
            chxmlstr += path.toxml()
            
        for text in self.texts:
            chxmlstr += text.toxml()

        chxmlstr += self.dynamics.toxml()
        chxmlstr += self.structure.toxml()
        chxmlstr += self.simulation.toxml()
            
        if chxmlstr:
            xmlstr += '>' + chxmlstr + '</ComponentType>'
        else:
            xmlstr += '/>'

        return xmlstr