'For exporting, set data on `node` from ourselves.'

def add_xml_to_node(self, node):

    xml_object = self.definition_to_xml(self.runtime.export_fs)
    for aside in self.runtime.get_asides(self):
        if aside.needs_serialization():
            aside_node = etree.Element('unknown_root', nsmap=XML_NAMESPACES)
            aside.add_xml_to_node(aside_node)
            xml_object.append(aside_node)
    self.clean_metadata_from_xml(xml_object)
    xml_object.tag = self.category
    node.tag = self.category
    for attr in sorted(own_metadata(self)):
        if ((attr not in self.metadata_to_strip) and (attr not in self.metadata_to_export_to_policy)):
            val = serialize_field(self._field_data.get(self, attr))
            try:
                xml_object.set(attr, val)
            except Exception:
                logging.exception(u'Failed    to    serialize    metadata    attribute    %s    with    value    %s    in    module    %s.    This    could    mean    data    loss!!!', attr, val, self.url_name)
    for (key, value) in self.xml_attributes.items():
        if (key not in self.metadata_to_strip):
            xml_object.set(key, serialize_field(value))
    if self.export_to_file():
        url_path = name_to_pathname(self.url_name)
        filepath = self._format_filepath(self.category, url_path)
        self.runtime.export_fs.makedir(os.path.dirname(filepath), recursive=True, allow_recreate=True)
        with self.runtime.export_fs.open(filepath, 'w') as fileobj:
            ElementTree(xml_object).write(fileobj, pretty_print=True, encoding='utf-8')
    else:
        node.clear()
        node.tag = xml_object.tag
        node.text = xml_object.text
        node.tail = xml_object.tail
        node.attrib.update(xml_object.attrib)
        node.extend(xml_object)
    node.set('url_name', self.url_name)
    if (self.category == 'course'):
        node.set('org', self.location.org)
        node.set('course', self.location.course)
