@Override
    public void write(Savable value, String name, Savable defVal) throws IOException {
        if (value == null || value.equals(defVal)) {
            return;
        }

        Element old = currentElement;

        // no longer tries to use class name as element name.  that makes things unnecessarily complicated.

        Element refElement = writtenSavables.get(value);
        // this object has already been written, so make an element that refers to the existing one.
        if (refElement != null) {
            String refID = XMLUtils.getAttribute(FormatVersion.VERSION, refElement, XMLExporter.ATTRIBUTE_REFERENCE_ID);

            // add the reference_ID to the referenced element if it didn't already have it
            if (refID.isEmpty()) {
                refID = value.getClass().getName() + "@" + value.hashCode();
                XMLUtils.setAttribute(refElement, XMLExporter.ATTRIBUTE_REFERENCE_ID, refID);
            }

            appendElement(name);
            XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_REFERENCE, refID);
        } else {
            appendElement(name);

            // this now always writes the class attribute even if the class name is also the element name.
            // for backwards compatibility, DOMInputCapsule will still try to get the class name from the element name if the
            // attribute isn't found.
            XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_CLASS, value.getClass().getName());
            
            // jME3 NEW: Append version number(s)
            int[] versions = SavableClassUtil.getSavableVersions(value.getClass());
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < versions.length; i++){
                sb.append(versions[i]);
                if (i != versions.length - 1){
                    sb.append(", ");
                }
            }
            XMLUtils.setAttribute(currentElement, XMLExporter.ATTRIBUTE_SAVABLE_VERSIONS, sb.toString());
            
            writtenSavables.put(value, currentElement);

            value.write(exporter);
        }

        currentElement = old;
    }
appends a new Element with the given name to currentElement, sets
currentElement to be new Element, and returns the new Element as well
jme3-plugins/src/xml/java/com/jme3/export/xml/DOMOutputCapsule.java