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 writeDocumentToStream.
public static void writeDocumentToStream(Document doc, OutputStream out) throws IOException {
OutputFormat format = OutputFormat.createPrettyPrint();
format.setTrimText(false);
format.setOmitEncoding(false);
XMLWriter writer = new XMLWriter(out, format);
writer.write(doc);
}
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 tdi-studio-se by Talend.
the class ChangeMappingFileMigrationTask method changeSAPHanaMappingFile.
private void changeSAPHanaMappingFile(URL url) {
File dir = new File(url.getFile());
File target = null;
if (dir.isDirectory()) {
File[] files = dir.listFiles();
for (File file : files) {
if (file.getName().equals("mapping_SAPHana.xml")) {
//$NON-NLS-1$
target = file;
break;
}
}
}
if (target != null) {
try {
SAXReader reader = new SAXReader();
Document document = reader.read(target);
Element root = document.getRootElement();
//$NON-NLS-1$
Element node = root.element("dbms");
//$NON-NLS-1$
Attribute attr = node.attribute("label");
if (attr != null && attr.getValue().equals("Mapping SAP Hana")) {
//$NON-NLS-1$
//$NON-NLS-1$
attr.setValue("Mapping SAPHana");
target.delete();
XMLWriter writer = new XMLWriter(new FileWriter(target));
writer.write(document);
writer.close();
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
}
use of org.dom4j.io.XMLWriter in project cpsolver by UniTime.
the class TimetableXMLSaver method save.
public void save(File outFile) throws Exception {
if (outFile == null)
outFile = new File(iOutputFolder, "solution.xml");
outFile.getParentFile().mkdirs();
sLogger.debug("Writting XML data to:" + outFile);
Document document = DocumentHelper.createDocument();
document.addComment("University Course Timetabling");
if (iSaveCurrent && getAssignment().nrAssignedVariables() != 0) {
StringBuffer comments = new StringBuffer("Solution Info:\n");
Map<String, String> solutionInfo = (getSolution() == null ? getModel().getExtendedInfo(getAssignment()) : getSolution().getExtendedInfo());
for (String key : new TreeSet<String>(solutionInfo.keySet())) {
String value = solutionInfo.get(key);
comments.append(" " + key + ": " + value + "\n");
}
document.addComment(comments.toString());
}
Element root = document.addElement("timetable");
doSave(root);
if (iShowNames) {
Progress.getInstance(getModel()).save(root);
try {
getSolver().getClass().getMethod("save", new Class[] { Element.class }).invoke(getSolver(), new Object[] { root });
} catch (Exception e) {
}
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(outFile);
(new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(document);
fos.flush();
fos.close();
fos = null;
} finally {
try {
if (fos != null)
fos.close();
} catch (IOException e) {
}
}
if (iConvertIds)
iIdConvertor.save();
}
Aggregations