Search in sources :

Example 1 with XSLTransformException

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);
}
Also used : Document(org.jdom2.Document)

Example 2 with XSLTransformException

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);
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Format(org.jdom2.output.Format) SimpleDateFormat(java.text.SimpleDateFormat) XSLTransformer(org.jdom2.transform.XSLTransformer) Document(org.jdom2.Document)

Example 3 with XSLTransformException

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();
    }
}
Also used : FacesContext(javax.faces.context.FacesContext) XsltPreparatorDocket(io.goobi.workflow.xslt.XsltPreparatorDocket) ServletOutputStream(javax.servlet.ServletOutputStream) ConfigurationException(org.apache.commons.configuration.ConfigurationException) HttpServletResponse(javax.servlet.http.HttpServletResponse) ServletContext(javax.servlet.ServletContext) XSLTransformException(org.jdom2.transform.XSLTransformException) IOException(java.io.IOException)

Aggregations

Document (org.jdom2.Document)2 XsltPreparatorDocket (io.goobi.workflow.xslt.XsltPreparatorDocket)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 FacesContext (javax.faces.context.FacesContext)1 ServletContext (javax.servlet.ServletContext)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ConfigurationException (org.apache.commons.configuration.ConfigurationException)1 Format (org.jdom2.output.Format)1 XMLOutputter (org.jdom2.output.XMLOutputter)1 XSLTransformException (org.jdom2.transform.XSLTransformException)1 XSLTransformer (org.jdom2.transform.XSLTransformer)1