Example usage for org.jdom2 Document clone

List of usage examples for org.jdom2 Document clone

Introduction

In this page you can find the example usage for org.jdom2 Document clone.

Prototype

@Override
public Document clone() 

Source Link

Document

This will return a deep clone of this Document.

Usage

From source file:org.mycore.frontend.xeditor.target.MCRDebugTarget.java

License:Open Source License

@Override
public void handleSubmission(ServletContext context, MCRServletJob job, MCREditorSession session,
        String parameter) throws Exception {
    job.getResponse().setContentType("text/html; charset=UTF-8");
    PrintWriter out = job.getResponse().getWriter();
    out.println("<html><body>");

    Map<String, String[]> parameters = job.getRequest().getParameterMap();
    session.getSubmission().setSubmittedValues(parameters);

    Document result = session.getEditedXML().clone();
    MCRChangeTracker tracker = session.getChangeTracker().clone();

    List<Step> steps = new ArrayList<Step>();
    for (String label; (label = tracker.undoLastBreakpoint(result)) != null;)
        steps.add(0, new Step(label, result.clone()));

    result = session.getEditedXML().clone();
    result = MCRChangeTracker.removeChangeTracking(result);

    result = session.getXMLCleaner().clean(result);
    steps.add(new Step("After cleaning", result));

    result = session.getPostProcessor().process(result);
    steps.add(new Step("After postprocessing", result));

    for (int i = 0; i < steps.size(); i++) {
        if (i == steps.size() - 3)
            outputParameters(parameters, out);

        steps.get(i).output(out);/*from  w w w.ja va 2s  .c om*/
    }

    out.println("</body></html>");
    out.close();
}