use of org.dom4j.io.XMLWriter in project cpsolver by UniTime.
the class Test method save.
/**
* Save the problem and the resulting assignment
* @param outputDir output directory
* @param assignment final assignment
*/
protected void save(File outputDir, Assignment<TeachingRequest.Variable, TeachingAssignment> assignment) {
try {
File outFile = new File(outputDir, "solution.xml");
FileOutputStream fos = new FileOutputStream(outFile);
try {
(new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(save(assignment));
fos.flush();
} finally {
fos.close();
}
} catch (Exception e) {
sLog.error("Failed to save solution: " + e.getMessage(), e);
}
}
use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.
the class WsdlGenerator method writeWsdl.
public static void writeWsdl(OutputStream xmlOut, String targetNamespace, String serviceName, List<WsdlInfoForNamespace> nsInfos) throws IOException {
Document wsdlDoc = makeWsdlDoc(nsInfos, serviceName, targetNamespace);
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(xmlOut, format);
writer.write(wsdlDoc);
writer.close();
}
use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.
the class DomUtil method toString.
/** Convert an Element to a String. */
public static String toString(Element env, boolean prettyPrint) {
if (prettyPrint) {
StringWriter buff = new StringWriter();
try {
OutputFormat format = OutputFormat.createPrettyPrint();
XMLWriter writer = new XMLWriter(buff, format);
writer.write(env);
writer.close();
} catch (IOException e) {
// ignore, since StringWriter doesn't throw IOExceptions
}
return buff.toString();
} else {
return env.asXML();
}
}
use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.
the class RightManager method writeXML.
private void writeXML(String fileName, Document document) throws IOException {
// Pretty print the document to output file
OutputFormat format = OutputFormat.createPrettyPrint();
BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
XMLWriter xmlWriter = new XMLWriter(writer, format);
xmlWriter.write(document);
writer.close();
}
use of org.dom4j.io.XMLWriter in project zm-mailbox by Zimbra.
the class DavMethod method toHttpMethod.
public HttpMethod toHttpMethod(DavContext ctxt, String targetUrl) throws IOException, DavException {
if (ctxt.getUpload() != null && ctxt.getUpload().getSize() > 0) {
PostMethod method = new PostMethod(targetUrl) {
@Override
public String getName() {
return getMethodName();
}
};
RequestEntity reqEntry;
if (ctxt.hasRequestMessage()) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLWriter writer = new XMLWriter(baos);
writer.write(ctxt.getRequestMessage());
reqEntry = new ByteArrayRequestEntity(baos.toByteArray());
} else {
// this could be a huge upload
reqEntry = new InputStreamRequestEntity(ctxt.getUpload().getInputStream(), ctxt.getUpload().getSize());
}
method.setRequestEntity(reqEntry);
return method;
}
return new GetMethod(targetUrl) {
@Override
public String getName() {
return getMethodName();
}
};
}
Aggregations