public static Document prepareForCloning(Document domainXml) {
        XPathFactory xpf = XPathFactory.instance();

        // remove uuid so it will be generated
        domainXml.getRootElement().removeChild("uuid");

        // remove mac address, so it will be generated
        XPathExpression<Element> macExpr = xpf.compile("/domain/devices/interface/mac", Filters.element());
        for (Element mac : macExpr.evaluate(domainXml)) {
            mac.getParentElement().removeChild("mac");
        }
        return domainXml;
    }
public static Document prepareForCloning ( Document domainXml ) { XPathFactory xpf = XPathFactory . instance ( ) ; domainXml . getRootElement ( ) . removeChild ( "uuid" ) ; XPathExpression < Element > macExpr = xpf . compile ( "/domain/devices/interface/mac" , Filters . element ( ) ) ; for ( Element mac : macExpr . evaluate ( domainXml ) ) { mac . getParentElement ( ) . removeChild ( "mac" ) ; } return domainXml ; }
remove elements that need to be unique per clone.