Example usage for org.dom4j.jaxb JAXBModifier setPruneElements

List of usage examples for org.dom4j.jaxb JAXBModifier setPruneElements

Introduction

In this page you can find the example usage for org.dom4j.jaxb JAXBModifier setPruneElements.

Prototype

public void setPruneElements(boolean pruneElements) 

Source Link

Document

Define whether the modified org.dom4j.Document must only be written to the output and pruned from the DOM4J tree.

Usage

From source file:org.dom4j.samples.jaxb.JAXBDemo.java

License:Open Source License

public void demoModifyWrite() {
    try {/*from w ww . ja  v  a 2s  .c o m*/
        File inputFile = new File("xml/jaxb/primer.xml");

        File outputFile = new File(outputDir, "testModifyWrite.xml");

        JAXBModifier jaxbModifier = new JAXBModifier("org.dom4j.test.primer", OutputFormat.createPrettyPrint());
        jaxbModifier.setPruneElements(true);
        jaxbModifier.setOutput(outputFile);
        jaxbModifier.addObjectModifier("/purchaseOrders/purchaseOrder", new PurchaseOrderDateModifier());
        Document doc = jaxbModifier.modify(inputFile);

        System.out.println("Pruned modified document:");
        System.out.println(doc.asXML());
        System.out.println();
    } catch (Exception e) {
        e.printStackTrace();
    }
}