class DTDResolver(etree.Resolver):

    def resolve(self, url, id, context):
        return self.resolve_string(data['dtd_file'], context)
xmldoc = StringIO(data['xml_file'])
parser = etree.XMLParser(dtd_validation=True, load_dtd=True)
parser.resolvers.add(DTDResolver())
Python xml etree DTD from a StringIO source?