public Document toDOM(Serializable structure) 
    {   
        RegularPumpingLemma pl = (RegularPumpingLemma)structure;
        Document doc = newEmptyDocument();
        Element elem = doc.getDocumentElement();        
        elem.appendChild(createElement(doc, LEMMA_NAME, null, pl.getTitle()));
        elem.appendChild(createElement(doc, FIRST_PLAYER, null, pl.getFirstPlayer()));
        elem.appendChild(createElement(doc, M_NAME, null, "" + pl.getM()));
        elem.appendChild(createElement(doc, W_NAME, null, "" + pl.getW()));
        elem.appendChild(createElement(doc, I_NAME, null, "" + pl.getI()));
        elem.appendChild(createElement(doc, X_NAME, null, "" + pl.getX().length()));
        elem.appendChild(createElement(doc, Y_NAME, null, "" + pl.getY().length()));
        
        //Encode the list of attempts.
        ArrayList attempts = pl.getAttempts();
        if(attempts != null && attempts.size() > 0)        
            for(int i = 0; i < attempts.size(); i++)
                elem.appendChild(createElement(doc, ATTEMPT, null, (String)attempts.get(i)));
        
        return doc;
    }