public function on_roles_end() {

        if (!$this->has_xml_writer()) {
            // no roles defined in moodle.xml so {link self::process_roles_role()}
            // was never executed
            $this->open_xml_writer('roles.xml');
            $this->write_xml('roles_definition', array());

        } else {
            // some roles were dumped into the file, let us close their wrapper now
            $this->xmlwriter->end_tag('roles_definition');
        }
        $this->close_xml_writer();
    }