@Override
    protected void writeChildren(XMLStreamWriter out)
        throws XMLStreamException {
        super.writeChildren(out);

        if (events != null) {
            for (Event event : events) {
                event.toXMLImpl(out);
            }
        }
        if (scopes != null) {
            for (Scope scope : scopes) {
                scope.toXMLImpl(out);
            }
        }
        if (units != null) {
            for (AbstractUnit unit : units) {
                 out.writeStartElement("unit");
                 out.writeAttribute(ID_ATTRIBUTE_TAG, unit.getId());
                 //out.writeAttribute("role", unit.getRole().toString().toLowerCase(Locale.US));
                 //out.writeAttribute("number", String.valueOf(unit.getNumber()));
                 out.writeEndElement();
            }
        }
        if (upgrades != null) {
            for (Map.Entry<UnitType, UnitType> entry : upgrades.entrySet()) {
                out.writeStartElement("upgrade");
                out.writeAttribute("from-id", entry.getKey().getId());
                out.writeAttribute("to-id", entry.getValue().getId());
                out.writeEndElement();
            }
        }
    }