Example usage for javax.xml.transform TransformerException printStackTrace

List of usage examples for javax.xml.transform TransformerException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.transform TransformerException printStackTrace.

Prototype

@Override
public void printStackTrace() 

Source Link

Document

Print the the trace of methods from where the error originated.

Usage

From source file:org.ojbc.util.camel.helper.OJBUtils.java

public static String getStringFromDocument(Document doc) {
    try {/*www. jav a2  s .  com*/
        DOMSource domSource = new DOMSource(doc);
        StringWriter writer = new StringWriter();
        StreamResult result = new StreamResult(writer);
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer = tf.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        transformer.transform(domSource, result);
        return writer.toString();
    } catch (TransformerException ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:org.ojbc.util.camel.processor.audit.FederatedQueryAuditLogger.java

private String getStringFromDocument(Document doc) {
    try {/* ww  w.jav a 2s.c  o m*/
        DOMSource domSource = new DOMSource(doc);
        StringWriter writer = new StringWriter();
        StreamResult result = new StreamResult(writer);
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer transformer = tf.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
        transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        transformer.transform(domSource, result);
        return writer.toString();
    } catch (TransformerException ex) {
        ex.printStackTrace();
        return null;
    }
}

From source file:org.openlmis.odkapi.service.ODKSubmissionService.java

public void saveZNZSurveyData(MultipartFile XMLSubmissionFile) throws ODKAccountNotFoundException,
        FacilityPictureNotFoundException, ODKCollectXMLSubmissionFileNotFoundException,
        ODKCollectXMLSubmissionParserConfigurationException, ODKCollectXMLSubmissionSAXException {
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    ODKZNZSurveySubmissionSAXHandler handler;
    handler = new ODKZNZSurveySubmissionSAXHandler();

    String filePath = "/public/odk-collect-submissions/";
    InputStream inputStream;/*  w  w w.j a  va2s  .  com*/
    FileOutputStream outputStream;

    // first save the xml submission file

    try {
        inputStream = XMLSubmissionFile.getInputStream();
        File newFile = new File(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        outputStream = new FileOutputStream(newFile);
        int read = 0;
        byte[] bytes = new byte[1024];

        while ((read = inputStream.read(bytes)) != -1) {
            outputStream.write(bytes, 0, read);
        }

        inputStream.close();
        outputStream.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // read the submission file into a string

    String xmlString = "";
    try {
        File savedSubmissionFile = new File(
                servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        xmlString = readFile(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()),
                Charset.defaultCharset());
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // use XML Formatter

    XmlFormatter formatter = new XmlFormatter();
    String formattedXmlSubmission = formatter.format(xmlString);

    // get input stream from the document object of the formatted xml

    Document xmlSubmissionDocument;
    try {
        xmlSubmissionDocument = stringToDom(formattedXmlSubmission);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    ByteArrayOutputStream outputStreamForDocument = new ByteArrayOutputStream();
    Source xmlSource = new DOMSource(xmlSubmissionDocument);
    Result outputTarget = new StreamResult(outputStreamForDocument);
    try {
        TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);

    } catch (TransformerConfigurationException transformerConfigurationException) {
        transformerConfigurationException.printStackTrace();
    } catch (TransformerException transformerException) {
        transformerException.printStackTrace();
    }

    InputStream inputStreamForDocument = new ByteArrayInputStream(outputStreamForDocument.toByteArray());

    try {
        SAXParser saxParser = saxParserFactory.newSAXParser();
        saxParser.parse(inputStreamForDocument, handler);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    odkSubmission = handler.getOdkSubmission();
    odkAccount = handler.getOdkAccount();
    pictures = handler.getPictures();

    ODKAccount tempAccount;

    tempAccount = odkAccountService.authenticate(odkAccount);

    odkSubmission.setOdkAccountId(tempAccount.getId());
    odkSubmission.setActive(true);
    this.insertODKSubmission(odkSubmission);
    Long lastODKSubmissionId = odkSubmissionRepository.getLastSubmissionId();

    // save storage part  with gps coordinates and pictures
    odkStorageSurveySubmission = handler.getOdkStorageSurveySubmission();
    odkStorageSurveySubmission.setODKSubmissionId(lastODKSubmissionId);
    ArrayList<byte[]> facilityPictures = getZNZSurveyPictures();

    for (int count = 0; count < facilityPictures.size(); count++) {
        try {
            Method picMethod = odkStorageSurveySubmission.getClass().getMethod(pictureSetMethods[count],
                    new Class[] { byte[].class });
            picMethod.invoke(odkStorageSurveySubmission, facilityPictures.get(count));
        } catch (IllegalAccessException ex) {
            // TO DO handle
        }

        catch (NoSuchMethodException ex) {
            // TO DO handle

        } catch (SecurityException ex) {
            // TO DO handle
        } catch (IllegalArgumentException ex) {
            // TO DO handle

        } catch (InvocationTargetException ex) {
            // TO DO handle
        }
    }

    odkStorageSurveySubmission.setTotalPercentage(getTotalPercentage(odkStorageSurveySubmission, 15));
    odkStorageSurveySubmissionRepository.insert(odkStorageSurveySubmission);

    // save lmis part
    odkLmisSurveySubmission = handler.getOdkLmisSurveySubmission();
    odkLmisSurveySubmission.setODKSubmissionId(lastODKSubmissionId);
    odkLmisSurveySubmission.setTotalPercentage(getTotalPercentage(odkLmisSurveySubmission, 11));
    odklmisSurveySubmissionRepository.insert(odkLmisSurveySubmission);

    // save r and r part
    odkRandRSubmission = handler.getOdkRandRSubmission();
    odkRandRSubmission.setODKSubmissionId(lastODKSubmissionId);
    odkRandRSubmission.setTotalPercentage(getTotalPercentage(odkRandRSubmission, 8));
    odkRandRSubmissionRepository.insert(odkRandRSubmission);

}

From source file:org.openlmis.odkapi.service.ODKSubmissionService.java

public void saveProofOfDeliverySurveyData(MultipartFile XMLSubmissionFile)
        throws ODKAccountNotFoundException, FacilityPictureNotFoundException,
        ODKCollectXMLSubmissionFileNotFoundException, ODKCollectXMLSubmissionParserConfigurationException,
        ODKCollectXMLSubmissionSAXException, ODKXFormNotFoundException {
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    ODKProofOfDeliverySubmissionSAXHandler handler;
    handler = new ODKProofOfDeliverySubmissionSAXHandler();

    String filePath = "/public/odk-collect-submissions/";
    InputStream inputStream;//from   ww w  .j ava2  s  . co m
    FileOutputStream outputStream;

    // first save the xml submission file

    try {
        inputStream = XMLSubmissionFile.getInputStream();
        File newFile = new File(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        outputStream = new FileOutputStream(newFile);
        int read = 0;
        byte[] bytes = new byte[1024];

        while ((read = inputStream.read(bytes)) != -1) {
            outputStream.write(bytes, 0, read);
        }

        inputStream.close();
        outputStream.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // read the submission file into a string

    String xmlString = "";
    try {
        File savedSubmissionFile = new File(
                servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        xmlString = readFile(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()),
                Charset.defaultCharset());
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // use XML Formatter

    XmlFormatter formatter = new XmlFormatter();
    String formattedXmlSubmission = formatter.format(xmlString);

    // get input stream from the document object of the formatted xml

    Document xmlSubmissionDocument;
    try {
        xmlSubmissionDocument = stringToDom(formattedXmlSubmission);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    ByteArrayOutputStream outputStreamForDocument = new ByteArrayOutputStream();
    Source xmlSource = new DOMSource(xmlSubmissionDocument);
    Result outputTarget = new StreamResult(outputStreamForDocument);
    try {
        TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);

    } catch (TransformerConfigurationException transformerConfigurationException) {
        transformerConfigurationException.printStackTrace();
    } catch (TransformerException transformerException) {
        transformerException.printStackTrace();
    }

    InputStream inputStreamForDocument = new ByteArrayInputStream(outputStreamForDocument.toByteArray());

    try {
        SAXParser saxParser = saxParserFactory.newSAXParser();
        saxParser.parse(inputStreamForDocument, handler);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    odkSubmission = handler.getOdkSubmission();
    odkAccount = handler.getOdkAccount();

    ODKAccount tempAccount;

    tempAccount = odkAccountService.authenticate(odkAccount);

    odkSubmission.setOdkAccountId(tempAccount.getId());
    odkSubmission.setActive(true);
    this.insertODKSubmission(odkSubmission);
    Long lastODKSubmissionId = odkSubmissionRepository.getLastSubmissionId();

    odkProofOfDeliverySubmissionData = handler.getOdkProofOfDeliverySubmissionData();

    this.insertODKProofOfDeliverySubmissionData(odkProofOfDeliverySubmissionData);
}

From source file:org.openlmis.odkapi.service.ODKSubmissionService.java

public void saveStockStatusSurveyData(MultipartFile XMLSubmissionFile) throws ODKAccountNotFoundException,
        FacilityPictureNotFoundException, ODKCollectXMLSubmissionFileNotFoundException,
        ODKCollectXMLSubmissionParserConfigurationException, ODKCollectXMLSubmissionSAXException {
    SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
    ODKStockStatusSubmissionSAXHandler handler;
    handler = new ODKStockStatusSubmissionSAXHandler();
    // To Do : the xml is not well formatted when stock status submission is done , find out why
    // this is a temporary solution

    String filePath = "/public/odk-collect-submissions/";
    InputStream inputStream;//from   w  w w  . ja  v  a 2 s  .  c  om
    FileOutputStream outputStream;

    // first save the xml submission file

    try {
        inputStream = XMLSubmissionFile.getInputStream();
        File newFile = new File(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        outputStream = new FileOutputStream(newFile);
        int read = 0;
        byte[] bytes = new byte[1024];

        while ((read = inputStream.read(bytes)) != -1) {
            outputStream.write(bytes, 0, read);
        }

        inputStream.close();
        outputStream.close();
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // read the submission file into a string

    String xmlString = "";
    try {
        File savedSubmissionFile = new File(
                servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()));
        xmlString = readFile(servletContext.getRealPath(filePath + XMLSubmissionFile.getOriginalFilename()),
                Charset.defaultCharset());
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    // use XML Formatter

    XmlFormatter formatter = new XmlFormatter();
    String formattedXmlSubmission = formatter.format(xmlString);

    // get input stream from the document object of the formatted xml

    Document xmlSubmissionDocument;
    try {
        xmlSubmissionDocument = stringToDom(formattedXmlSubmission);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    ByteArrayOutputStream outputStreamForDocument = new ByteArrayOutputStream();
    Source xmlSource = new DOMSource(xmlSubmissionDocument);
    Result outputTarget = new StreamResult(outputStreamForDocument);
    try {
        TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget);

    } catch (TransformerConfigurationException transformerConfigurationException) {
        transformerConfigurationException.printStackTrace();
    } catch (TransformerException transformerException) {
        transformerException.printStackTrace();
    }

    InputStream inputStreamForDocument = new ByteArrayInputStream(outputStreamForDocument.toByteArray());

    try {
        SAXParser saxParser = saxParserFactory.newSAXParser();
        saxParser.parse(inputStreamForDocument, handler);
    } catch (SAXException exception) {
        throw new ODKCollectXMLSubmissionSAXException();

    } catch (IOException e) {
        throw new ODKCollectXMLSubmissionFileNotFoundException();
    } catch (ParserConfigurationException e) {
        throw new ODKCollectXMLSubmissionParserConfigurationException();
    }

    odkSubmission = handler.getOdkSubmission();
    odkAccount = handler.getOdkAccount();

    ODKAccount tempAccount;

    tempAccount = odkAccountService.authenticate(odkAccount);

    odkSubmission.setOdkAccountId(tempAccount.getId());
    odkSubmission.setActive(true);
    this.insertODKSubmission(odkSubmission);
    Long lastODKSubmissionId = odkSubmissionRepository.getLastSubmissionId();

    listODKStockStatusSubmissions = handler.getListODKStockStatusSubmissions();

    for (ODKStockStatusSubmission odkStockStatusSubmission : listODKStockStatusSubmissions) {
        odkStockStatusSubmission.setODKSubmissionId(lastODKSubmissionId);
        odkStockStatusSubmission.setActive(true);
        this.insertStockStatus(odkStockStatusSubmission);
    }

}

From source file:org.patientview.patientview.EmailUtils.java

private static String getNodeAsString(Node node) {
    String nodeAsString = "";
    try {//from  w  w w . j  a  v a2 s.  com
        // Set up the output transformer
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer trans = transformerFactory.newTransformer();
        trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        trans.setOutputProperty(OutputKeys.INDENT, "yes");

        // Print the DOM node

        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        DOMSource source = new DOMSource(node);
        trans.transform(source, result);
        String xmlString = sw.toString();

        nodeAsString += xmlString;
    } catch (TransformerException e) {
        LOGGER.error("Failed to transform node because {}.", e.getMessage());
        if (LOGGER.isDebugEnabled()) {
            e.printStackTrace();
        }
        // Just return the blank string
    }

    return nodeAsString;
}

From source file:org.vivoweb.harvester.fetch.WOSFetch.java

/**
 * @param documentNode a DOM node to be changed into a properly indented string
 * @return The indented string containing the node and sub-nodes
 *//*ww w . j a v a 2  s .c  o  m*/
private String nodeToString(Node documentNode) {
    StreamResult result = null;
    try {
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

        result = new StreamResult(new StringWriter());
        DOMSource domSource = new DOMSource(documentNode);
        transformer.transform(domSource, result);
    } catch (TransformerException e) {
        e.printStackTrace();
    } catch (TransformerFactoryConfigurationError e1) {
        e1.printStackTrace();
    }

    return result.getWriter().toString();
}

From source file:org.webcurator.core.profiles.HeritrixProfile.java

/**
 * Convert the HeritrixProfile object to its XML string.
 * @return the XML string that represents the Heritrix profile.
 *///from  w  w  w  .j av  a  2  s .c  o  m
public String toString() {
    try {
        StringWriter stringWriter = new StringWriter(4096);
        StreamResult result = new StreamResult(stringWriter);
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        Source source = new CrawlSettingsSAXSource(crawlerSettings);
        transformer.transform(source, result);
        return stringWriter.toString();
    } catch (TransformerException ex) {
        ex.printStackTrace();
        return "[ERROR CONVERTING PROFILE TO STRING]";
    }
}

From source file:perflab.LoadrunnerWrapper.java

/**
 * @param transactions - ArrayList of LoadRunnerTransaction objects
 * @param summaryFile  - location of xml summary file to be generated out of transaction objects in jUnit format
 * @return//from  w ww.  jav a  2  s.  c  o  m
 */
private void generatejUnitReport(ArrayList<LoadRunnerTransaction> transactions, String summaryFile) {

    getLog().info("Transformation to jUnit XML started ...");

    String stringReport = "";

    try {
        /*
         * http://llg.cubic.org/docs/junit/
         <testsuite tests="3" time="42.5">
           <testcase classname="ZZZ_1" name="ZZZ_1" time="10.1"/>
           <testcase classname="ZZZ_2" name="ZZZ_2" time="11.7"/>
           <testcase classname="ZZZ_3" name="ZZZ_3" time="12.2">
            <!--failure type="NotEnoughFoo"> too slow </failure-->
           </testcase>
        </testsuite>
         */

        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

        // root elements
        org.w3c.dom.Document doc = (org.w3c.dom.Document) docBuilder.newDocument();
        org.w3c.dom.Element testsuiteElement = (org.w3c.dom.Element) doc.createElement("testsuite");
        testsuiteElement.setAttribute("tests", String.valueOf(transactions.size()));
        //testsuiteElement.setAttribute("time", "total test duration");
        doc.appendChild(testsuiteElement);

        ////////////////////////////////////////////////////////////////////////////

        for (LoadRunnerTransaction tr : this.transactions) {

            getLog().info("Dump " + tr.getName());

            org.w3c.dom.Element testcaseElement = doc.createElement("testcase");
            testcaseElement.setAttribute("classname", "load.ResponseTime");
            testcaseElement.setAttribute("name", tr.getName());
            testcaseElement.setAttribute("time", String.valueOf(tr.getAvgRT()));

            testsuiteElement.appendChild(testcaseElement);
        }

        ////////////////////////////////////////////////////////////////////////////
        // write the content into xml file
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

        DOMSource source = new DOMSource(doc);

        File lr_report = new File(summaryFile);
        StreamResult result = new StreamResult(lr_report);

        transformer.transform(source, result);

        getLog().info("File saved in " + lr_report.getAbsolutePath());

    } catch (ParserConfigurationException pce) {
        getLog().error(pce.getMessage());
        pce.printStackTrace();
    } catch (TransformerException tfe) {
        getLog().error(tfe.getMessage());
        tfe.printStackTrace();
    }
}

From source file:perflab.LoadrunnerWrapper.java

/**
 * @param transactions - ArrayList of LoadRunnerTransaction objects
 * @return//from   w ww.j a v a  2 s  . co  m
 */
private void generatePerfPublisherReport(ArrayList<LoadRunnerTransaction> transactions, String xmlFile) {
    getLog().info("Transformation to XML started ...");
    try {

        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

        // root elements
        org.w3c.dom.Document doc = (org.w3c.dom.Document) docBuilder.newDocument();
        org.w3c.dom.Element reportElement = (org.w3c.dom.Element) doc.createElement("report");
        doc.appendChild(reportElement);

        ////////////////////////////////////////////////////////////////////////////

        //<categories>
        //   <category name="memory" scale="mb">
        //       <observations>
        //           <observation name="Server 1">100</observation>
        //           <observation name="Server 2">200</observation>
        //       </observations>
        //   </category>

        //   <category name="disk" scale="gb">
        //       <observations>
        //           <observation name="Server 1">41</observation>
        //           <observation name="Server 2">58</observation>
        //       </observations>
        //   </category>
        //</categories>

        // start element
        org.w3c.dom.Element startElement = (org.w3c.dom.Element) doc.createElement("start");
        reportElement.appendChild(startElement);

        // date element
        org.w3c.dom.Element date = (org.w3c.dom.Element) doc.createElement("date");
        startElement.appendChild(date);

        date.setAttribute("format", "YYYYMMDD");
        date.setAttribute("val", "20100922");

        // time element
        org.w3c.dom.Element time = (org.w3c.dom.Element) doc.createElement("date");
        startElement.appendChild(time);

        time.setAttribute("format", "HHMMSS");
        time.setAttribute("val", "215935");

        ////////////////////////////////////////////////////////////////////////////

        //<test name="Smoke test" executed="yes" categ="Smoke test">

        //<description>Tests if ATE LAN socket and communication works.</description>

        //<result>
        //   <success passed="yes" state ="100" hasTimedOut="no" />
        //   <compiletime unit="s" mesure="0" isRelevant="yes" />
        //   <performance unit="%" mesure="0" isRelevant="yes" />
        //   <executiontime unit="s" mesure="12" isRelevant="yes" />
        //   <metrics>
        //      <006_My_Benefits unit="sec" mesure="0.115" isRelevant="yes"/>
        //      <007_My_Timesheet unit="sec" mesure="1.247" isRelevant="yes"/>
        //   </metrics>
        //</result>
        //</test>
        //</report>

        ////////////////////////////////////////////////////////////////////////////
        // test element
        org.w3c.dom.Element testElement = doc.createElement("test");
        reportElement.appendChild(testElement);

        testElement.setAttribute("name", "Smoke test");
        testElement.setAttribute("executed", "yes");
        testElement.setAttribute("categ", "Smoke test");

        // description element
        org.w3c.dom.Element descriptionElement = doc.createElement("description");
        descriptionElement.appendChild(doc.createTextNode("This is the best Load test ever executed..."));
        reportElement.appendChild(descriptionElement);

        ////////////////////////////////////////////////////////////////////////////
        // result
        org.w3c.dom.Element resultElement = doc.createElement("result");
        reportElement.appendChild(resultElement);

        org.w3c.dom.Element successElement = doc.createElement("success");
        resultElement.appendChild(successElement);

        org.w3c.dom.Element compiletimeElement = doc.createElement("compiletime");
        resultElement.appendChild(compiletimeElement);

        org.w3c.dom.Element performanceElement = doc.createElement("performance");
        resultElement.appendChild(performanceElement);

        org.w3c.dom.Element executiontimeElement = doc.createElement("executiontime");
        resultElement.appendChild(executiontimeElement);

        org.w3c.dom.Element metricsElement = doc.createElement("metrics");
        resultElement.appendChild(metricsElement);

        ////////////////////////////////////////////////////////////////////////////

        for (LoadRunnerTransaction tr : this.transactions) {
            //<006_My_Benefits unit="sec" mesure="0.115" isRelevant="yes"/>
            String trName = "tr_" + tr.getName();
            getLog().info("Dump " + trName);

            org.w3c.dom.Element trElement = doc.createElement(trName);
            trElement.setAttribute("unit", "sec");
            trElement.setAttribute("mesure", String.valueOf(tr.getAvgRT()));
            trElement.setAttribute("isRelevant", "yes");
            metricsElement.appendChild(trElement);
        }

        ////////////////////////////////////////////////////////////////////////////
        // write the content into xml file
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");

        DOMSource source = new DOMSource(doc);

        File lr_report = new File(xmlFile);
        StreamResult result = new StreamResult(lr_report);

        transformer.transform(source, result);

        getLog().info("File saved in " + lr_report.getAbsolutePath());

    } catch (ParserConfigurationException pce) {
        getLog().error(pce.getMessage());
        pce.printStackTrace();
    } catch (TransformerException tfe) {
        getLog().error(tfe.getMessage());
        tfe.printStackTrace();
    }
}