private Savable readSavableFromCurrentElement(Savable defVal) throws IOException {
        if (currentElement == null || !currentElement.hasAttributes()) {
            return defVal;
        }

        String reference = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, XMLExporter.ATTRIBUTE_REFERENCE);
        if (!reference.isEmpty()) {
            return referencedSavables.get(reference);
        } else {
            // for backwards compatibility with old XML files.  previous version of DOMOutputCapsule would only write the class attribute
            // if the element name wasn't the class name.
            String className = currentElement.getNodeName();
            if (XMLUtils.hasAttribute(importer.getFormatVersion(), currentElement, XMLExporter.ATTRIBUTE_CLASS)) {
                className = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, XMLExporter.ATTRIBUTE_CLASS);
            } else if (defVal != null) {
                className = defVal.getClass().getName();
            }

            Savable tmp = null;
            try {
                tmp = SavableClassUtil.fromName(className);
            } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
                throw new IOException(e);
            }
            
            String versionsStr = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, XMLExporter.ATTRIBUTE_SAVABLE_VERSIONS);
            if (versionsStr != null && !versionsStr.equals("")){
                String[] versionStr = versionsStr.split(",");
                classHierarchyVersions = new int[versionStr.length];
                try {
                    for (int i = 0; i < classHierarchyVersions.length; i++) {
                        classHierarchyVersions[i] = Integer.parseInt(versionStr[i].trim());
                    }
                } catch (NumberFormatException nfe) {
                    throw new IOException(nfe);
                }
            }else{
                classHierarchyVersions = null;
            }
            
            String refID = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, XMLExporter.ATTRIBUTE_REFERENCE_ID);

            // what does this line do?  guessing backwards compatibility?
            if (refID.isEmpty()) refID = XMLUtils.getAttribute(importer.getFormatVersion(), currentElement, "id");

            if (!refID.isEmpty()) referencedSavables.put(refID, tmp);
            
            if (tmp != null) {
                // Allows reading versions from this savable
                savable = tmp;

                tmp.read(importer);

                return tmp;
            } else {
                return defVal;
            }
        }
    }
Part of the jME XML IO system as introduced in the Google Code jmexml project.

@author Kai Rabien (hevee) - original author of the code.google.com jmexml project
@author Doug Daniels (dougnukem) - adjustments for jME 2.0 and Java 1.5
@author blaine
jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java