'Render the template, given the definition xml_data'

def render_template(self, system, xml_data):

    xmltree = etree.fromstring(xml_data)
    if ('impl' in xmltree.attrib):
        template_name = xmltree.attrib['impl']
    else:
        dog_stats_api.increment(DEPRECATION_VSCOMPAT_EVENT, tags=['location:customtag_descriptor_render_template'])
        child_impl = xmltree.find('impl')
        if (child_impl is not None):
            template_name = child_impl.text
        else:
            raise Exception('Could    not    find    impl    attribute    in    customtag    {0}'.format(self.location))
    params = dict(xmltree.items())
    template_loc = self.location.replace(category='custom_tag_template', name=template_name)
    template_module = system.load_item(template_loc)
    template_module_data = template_module.data
    template = Template(template_module_data)
    return template.render(**params)
