use of org.jdom2.transform.XSLTransformException in project goobi-workflow by intranda.
the class XsltPreparatorDocket method startTransformation.
public void startTransformation(Process p, OutputStream out, String filename) throws ConfigurationException, XSLTransformException, IOException {
Document doc = createDocument(p, true, true);
XmlTransformation(out, doc, filename);
}
use of org.jdom2.transform.XSLTransformException in project goobi-workflow by intranda.
the class XsltPreparatorDocket method XmlTransformation.
/**
* This method transforms the xml log using a xslt file and opens a new window with the output file
*
* @param out ServletOutputStream
* @param doc the xml document to transform
* @param filename the filename of the xslt
* @throws XSLTransformException
* @throws IOException
*/
public void XmlTransformation(OutputStream out, Document doc, String filename) throws XSLTransformException, IOException {
Document docTrans = new Document();
if (filename != null && filename.equals("")) {
XSLTransformer transformer;
transformer = new XSLTransformer(filename);
docTrans = transformer.transform(doc);
} else {
docTrans = doc;
}
Format format = Format.getPrettyFormat();
format.setEncoding("utf-8");
XMLOutputter xmlOut = new XMLOutputter(format);
xmlOut.output(docTrans, out);
}
use of org.jdom2.transform.XSLTransformException in project goobi-workflow by intranda.
the class ProcessBean method TransformXml.
/**
* transforms xml logfile with given xslt and provides download
*/
public void TransformXml() {
FacesContext facesContext = FacesContextHelper.getCurrentFacesContext();
if (!facesContext.getResponseComplete()) {
String OutputFileName = "export.xml";
/*
* Vorbereiten der Header-Informationen
*/
HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
ServletContext servletContext = (ServletContext) facesContext.getExternalContext().getContext();
String contentType = servletContext.getMimeType(OutputFileName);
response.setContentType(contentType);
response.setHeader("Content-Disposition", "attachment;filename=\"" + OutputFileName + "\"");
response.setContentType("text/xml");
try {
ServletOutputStream out = response.getOutputStream();
XsltPreparatorDocket export = new XsltPreparatorDocket();
export.startTransformation(out, this.myProzess, this.selectedXslt);
out.flush();
} catch (ConfigurationException e) {
Helper.setFehlerMeldung("could not create logfile: ", e);
} catch (XSLTransformException e) {
Helper.setFehlerMeldung("could not create transformation: ", e);
} catch (IOException e) {
Helper.setFehlerMeldung("could not create transformation: ", e);
}
facesContext.responseComplete();
}
}
Aggregations