use of javax.xml.transform.TransformerFactory in project karaf by apache.
the class XmlUtils method transformer.
private static Transformer transformer(Source xsltSource) throws TransformerConfigurationException {
TransformerFactory tf = TRANSFORMER_FACTORY.get();
if (tf == null) {
tf = TransformerFactory.newInstance();
TRANSFORMER_FACTORY.set(tf);
}
return tf.newTransformer(xsltSource);
}
use of javax.xml.transform.TransformerFactory in project karaf by apache.
the class XmlUtils method transformer.
public static Transformer transformer() throws TransformerConfigurationException {
TransformerFactory tf = TRANSFORMER_FACTORY.get();
if (tf == null) {
tf = TransformerFactory.newInstance();
TRANSFORMER_FACTORY.set(tf);
}
return tf.newTransformer();
}
use of javax.xml.transform.TransformerFactory in project jena by apache.
the class DOM2Model method load.
/**
* Parse a DOM Node with the RDF/XML parser, loading the triples into the
* associated Model. Known not to work with Java 1.4.1.
*
* @param document
*/
public void load(Node document) {
Source input = new DOMSource(document);
// Make a SAXResult object using this handler
SAXResult output = new SAXResult(this);
output.setLexicalHandler(this);
// Run transform
TransformerFactory xformFactory = TransformerFactory.newInstance();
try {
Transformer idTransform = xformFactory.newTransformer();
idTransform.transform(input, output);
} catch (FatalParsingErrorException e) {
// Old code ignored this,
// given difficult bug report, don't be silent.
logger.error("Unexpected exception in DOM2Model", e);
} catch (RuntimeException rte) {
throw rte;
} catch (Exception nrte) {
throw new JenaException(nrte);
} finally {
close();
}
}
use of javax.xml.transform.TransformerFactory in project poi by apache.
the class ExcelToHtmlConverter method main.
/**
* Java main() interface to interact with {@link ExcelToHtmlConverter}
*
* <p>
* Usage: ExcelToHtmlConverter infile outfile
* </p>
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
* as HTML into outfile
* @throws TransformerException
* @throws Exception
*/
public static void main(String[] args) throws IOException, ParserConfigurationException, TransformerException {
if (args.length < 2) {
System.err.println("Usage: ExcelToHtmlConverter <inputFile.xls> <saveTo.html>");
return;
}
System.out.println("Converting " + args[0]);
System.out.println("Saving output to " + args[1]);
Document doc = ExcelToHtmlConverter.process(new File(args[0]));
DOMSource domSource = new DOMSource(doc);
StreamResult streamResult = new StreamResult(new File(args[1]));
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
// TODO set encoding from a command argument
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "no");
serializer.setOutputProperty(OutputKeys.METHOD, "html");
serializer.transform(domSource, streamResult);
}
use of javax.xml.transform.TransformerFactory in project poi by apache.
the class ExcelToFoConverter method main.
/**
* Java main() interface to interact with {@link ExcelToFoConverter}
*
* <p>
* Usage: ExcelToHtmlConverter infile outfile
* </p>
* Where infile is an input .xls file ( Word 97-2007) which will be rendered
* as XSL FO into outfile
*/
public static void main(String[] args) throws Exception {
if (args.length < 2) {
System.err.println("Usage: ExcelToFoConverter <inputFile.xls> <saveTo.xml>");
return;
}
System.out.println("Converting " + args[0]);
System.out.println("Saving output to " + args[1]);
Document doc = ExcelToHtmlConverter.process(new File(args[0]));
DOMSource domSource = new DOMSource(doc);
StreamResult streamResult = new StreamResult(new File(args[1]));
TransformerFactory tf = TransformerFactory.newInstance();
Transformer serializer = tf.newTransformer();
// TODO set encoding from a command argument
serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
serializer.setOutputProperty(OutputKeys.INDENT, "no");
serializer.setOutputProperty(OutputKeys.METHOD, "xml");
serializer.transform(domSource, streamResult);
}
Aggregations