use of javax.xml.transform.TransformerFactoryConfigurationError in project midpoint by Evolveum.
the class SchemaDistMojo method serializeXml.
private void serializeXml(Document dom, Path filePath, File workDir, File outDir) throws MojoFailureException, MojoExecutionException {
Path fileRelPath = workDir.toPath().relativize(filePath);
File outFile = new File(outDir, fileRelPath.toString());
initializeOutDir(outFile.getParentFile());
try {
DOMUtil.serializeDOMToFile(dom, outFile);
} catch (TransformerFactoryConfigurationError | TransformerException e) {
throw new MojoExecutionException("Error serializing modified file " + fileRelPath + " to XML: " + e.getMessage(), e);
}
}
use of javax.xml.transform.TransformerFactoryConfigurationError in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateXslFile.
private void generateXslFile(String resource, String xslfile, String cssfile, String folder) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
org.w3c.dom.Document document = builder.parse(new File(resource));
org.w3c.dom.Element rootElement = document.getDocumentElement();
//$NON-NLS-1$
NodeList list = rootElement.getElementsByTagName("style");
org.w3c.dom.Element element = (org.w3c.dom.Element) list.item(0);
String value = element.getChildNodes().item(0).getNodeValue();
if (value != null) {
if (folder != null) {
//$NON-NLS-1$
CSSParserUtils.createCssFile(value, folder + File.separator + "default.css");
}
if (cssfile != null && !cssfile.equals("")) {
//$NON-NLS-1$
if (folder != null) {
String cssName = new File(cssfile).getName();
if (cssName.equalsIgnoreCase("default.css")) {
//$NON-NLS-1$
//$NON-NLS-1$
cssName = "User_" + cssName;
}
File file = new File(folder + File.separator + cssName);
if (!file.exists()) {
file.createNewFile();
}
FileCopyUtils.copy(cssfile, folder + File.separator + cssName);
}
CSSRuleList ruleList = CSSParserUtils.parserCSSSelectors(null, cssfile);
if (ruleList == null) {
return;
} else {
String newValue = CSSParserUtils.generateCssStyle(cssfile, ruleList, value);
element.getChildNodes().item(0).setNodeValue(newValue);
// replace the old value and generate a new xsl file
DOMSource ds = new DOMSource(document);
StreamResult sr = new StreamResult(new File(xslfile));
TransformerFactory.newInstance().newTransformer().transform(ds, sr);
}
}
}
} catch (ParserConfigurationException e) {
ExceptionHandler.process(e);
} catch (SAXException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
} catch (TransformerConfigurationException e) {
ExceptionHandler.process(e);
} catch (TransformerException e) {
ExceptionHandler.process(e);
} catch (TransformerFactoryConfigurationError e) {
ExceptionHandler.process(e);
}
}
use of javax.xml.transform.TransformerFactoryConfigurationError in project geode by apache.
the class ConfigurationResponse method describeConfig.
public String describeConfig() {
StringBuffer sb = new StringBuffer();
if (requestedConfiguration.isEmpty()) {
sb.append("Received an empty shared configuration");
} else {
Set<Entry<String, Configuration>> entries = requestedConfiguration.entrySet();
Iterator<Entry<String, Configuration>> iter = entries.iterator();
while (iter.hasNext()) {
Entry<String, Configuration> entry = iter.next();
String configType = entry.getKey();
Configuration config = entry.getValue();
if (config != null) {
sb.append("\n***************************************************************");
sb.append("\nConfiguration for '" + configType + "'");
sb.append("\n\nJar files to deployed");
Set<String> jarNames = config.getJarNames();
Iterator<String> jarIter = jarNames.iterator();
int jarCounter = 0;
while (jarIter.hasNext()) {
sb.append("\n" + ++jarCounter + "." + jarIter.next());
}
try {
String cacheXmlContent = config.getCacheXmlContent();
if (StringUtils.isNotBlank(cacheXmlContent)) {
sb.append("\n" + XmlUtils.prettyXml(cacheXmlContent));
}
} catch (IOException | TransformerFactoryConfigurationError | TransformerException | SAXException | ParserConfigurationException e) {
throw new InternalGemFireError(e);
}
}
}
}
return sb.toString();
}
use of javax.xml.transform.TransformerFactoryConfigurationError in project apps-android-commons by commons-app.
the class Utils method getStringFromDOM.
public static String getStringFromDOM(Node dom) {
Transformer transformer = null;
try {
transformer = TransformerFactory.newInstance().newTransformer();
} catch (TransformerConfigurationException | TransformerFactoryConfigurationError e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StringWriter outputStream = new StringWriter();
DOMSource domSource = new DOMSource(dom);
StreamResult strResult = new StreamResult(outputStream);
try {
transformer.transform(domSource, strResult);
} catch (TransformerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return outputStream.toString();
}
use of javax.xml.transform.TransformerFactoryConfigurationError in project ddf by codice.
the class XPathHelper method print.
/**
* @param xmlDeclaration
* @param indent
* @return
*/
public String print(String xmlDeclaration, String indent) {
Transformer serializer;
try {
serializer = tf.newTransformer();
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, xmlDeclaration);
serializer.setOutputProperty(OutputKeys.INDENT, indent);
serializer.setOutputProperty(OutputPropertiesFactory.S_KEY_CONTENT_HANDLER, org.apache.xml.serializer.ToXMLStream.class.getName());
StringWriter writer = new StringWriter();
serializer.transform(new DOMSource(document), new StreamResult(writer));
return writer.toString();
} catch (TransformerFactoryConfigurationError | TransformerException e) {
LOGGER.debug(e.getMessage(), e);
}
return null;
}
Aggregations