'If the definition data is invalid xml, export it wrapped in an "error"
tag.  If it is valid, export without the wrapper.
NOTE: There may still be problems with the valid xml--it could be
missing required attributes, could have the wrong tags, refer to missing
files, etc.  That would just get re-wrapped on import.'

def export_to_xml(self, resource_fs):

    try:
        xml = etree.fromstring(self.contents)
        return etree.tostring(xml, encoding='unicode')
    except etree.XMLSyntaxError:
        root = etree.Element('error')
        root.text = self.contents
        err_node = etree.SubElement(root, 'error_msg')
        err_node.text = self.error_msg
        return etree.tostring(root, encoding='unicode')
