use of javax.xml.transform.Result in project cayenne by apache.
the class DefaultUpgradeService method saveDocument.
protected void saveDocument(UpgradeUnit upgradeUnit) {
try {
Source input = new DOMSource(upgradeUnit.getDocument());
Result output = new StreamResult(Util.toFile(upgradeUnit.getResource().getURL()));
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(input, output);
} catch (Exception ex) {
logger.warn("Can't save the document: ", ex);
}
}
use of javax.xml.transform.Result in project cxf by apache.
the class JAXBUtils method generateJaxbSchemas.
public static List<DOMResult> generateJaxbSchemas(JAXBContext context, final Map<String, DOMResult> builtIns) throws IOException {
final List<DOMResult> results = new ArrayList<>();
context.generateSchema(new SchemaOutputResolver() {
@Override
public Result createOutput(String ns, String file) throws IOException {
DOMResult result = new DOMResult();
if (builtIns.containsKey(ns)) {
DOMResult dr = builtIns.get(ns);
result.setSystemId(dr.getSystemId());
results.add(dr);
return result;
}
result.setSystemId(file);
results.add(result);
return result;
}
});
return results;
}
use of javax.xml.transform.Result in project linuxtools by eclipse.
the class AbstractDataAdapter method toString.
@Override
public String toString() {
String ret = null;
Source source = new DOMSource(getDocument());
StringWriter stw = new StringWriter();
Result result = new StreamResult(stw);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer xformer;
try {
xformer = factory.newTransformer();
// $NON-NLS-1$ //$NON-NLS-2$
xformer.setOutputProperty("indent", "yes");
xformer.transform(source, result);
ret = stw.toString();
} catch (TransformerException e) {
e.printStackTrace();
}
return ret;
}
use of javax.xml.transform.Result in project knime-core by knime.
the class NodeDescriptionConverter method buildDocumentationFor.
/**
* Gets the {@link RepositoryManager} and transforms all NodeDescriptions
* into HTML files, which are placed into the roots HTML directory.
*
* @param pluginId the id of the plugin for which the help files should be
* generated
* @param destinationDir directory, where the created/modified files should
* be written to. If <code>null</code> they are written directly
* into the plugin's directory.
* @throws Exception if something goes wrong
*/
public synchronized void buildDocumentationFor(final String pluginId, final File destinationDir) throws Exception {
final Root root = RepositoryManager.INSTANCE.getRoot();
if (m_monitor != null) {
Display d = Display.getDefault();
d.syncExec(new Runnable() {
@Override
public void run() {
if (m_monitor.isCanceled()) {
m_canceled = true;
return;
}
if (m_first) {
m_monitor.beginTask("Processing " + m_pluginID, m_nrPlugins * root.getChildren().length);
m_first = false;
} else {
m_monitor.subTask("Processing " + m_pluginID);
}
}
});
}
if (m_canceled) {
return;
}
m_pluginID = pluginId;
if (destinationDir == null) {
m_destinationDir = getPluginDir();
} else {
m_destinationDir = destinationDir;
}
File nodesDir = new File(m_destinationDir, HTML_DIR + File.separator + NODES_DIR);
if (!nodesDir.exists() && !nodesDir.mkdirs()) {
throw new IOException("Could not create directory '" + nodesDir + "'");
}
File tocsDir = new File(m_destinationDir, TOC_DIR);
if (!tocsDir.exists() && !tocsDir.mkdirs()) {
throw new IOException("Could not create directory '" + tocsDir + "'");
}
parsePluginXML();
if (m_dialog != null) {
m_dialog.setCancelable(false);
}
// processing
processAll(root.getChildren(), null);
// at the end -> persist plugin.xml
Document doc = m_pluginXML;
Source src = new DOMSource(doc);
File f = new File(m_destinationDir, m_isFragment ? "fragment.xml" : "plugin.xml");
Result streamResult = new StreamResult(f);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.transform(src, streamResult);
// at the end add the two dependencies to the manifest file
// org.eclipse.help, org.eclipse.help.ui
updateManifest();
}
use of javax.xml.transform.Result in project knime-core by knime.
the class NodeDescriptionConverter method writeNodeTocFile.
private void writeNodeTocFile(final Document root, final String fileName) throws IOException, TransformerException {
Document doc = root;
Source src = new DOMSource(doc);
File f = new File(m_destinationDir, TOC_DIR + File.separator + fileName + ".xml");
Result streamResult = new StreamResult(f);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "yes");
serializer.transform(src, streamResult);
}
Aggregations