List of usage examples for org.jdom2.output XMLOutputter XMLOutputter
public XMLOutputter(XMLOutputProcessor processor)
XMLOutputter
with the specified XMLOutputProcessor. From source file:de.danielluedecke.zettelkasten.tasks.export.ExportToXmlTask.java
License:Open Source License
@Override protected Object doInBackground() { // Your Task's code here. This method runs // on a background thread, so don't reference // the Swing GUI from here. // prevent task from processing when the file path is incorrect // if no file exists, exit task if (null == filepath) { showOkMessage = false;/*w w w.j a v a2 s .co m*/ return null; } // check whether file already exists if (filepath.exists()) { // file exists, ask user to overwrite it... int optionDocExists = JOptionPane.showConfirmDialog(null, resourceMap.getString("askForOverwriteFileMsg", "", filepath.getName()), resourceMap.getString("askForOverwriteFileTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); // if the user does *not* choose to overwrite, quit... if (optionDocExists != JOptionPane.YES_OPTION) { // don't show "export was OK" message in main frame showOkMessage = false; return null; } } int contentsize; int counter; // first of all, create a new, empty xml-document Document exportDoc = new Document(new Element("zettelkasten")); // yet everything is ok... exportOk = true; // create a list of all elements from the main xml file try { // get the size of the export data, used for progressbar contentsize = exportentries.size(); // go through all elements of the data file for (counter = 0; counter < exportentries.size(); counter++) { // add the headline to our final export document exportDoc.getRootElement().addContent(exportEntries(counter)); // update progress bar setProgress(counter, 0, contentsize); } } catch (IllegalStateException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); // show warning message box JOptionPane.showMessageDialog(null, resourceMap.getString("errorExportMsg"), resourceMap.getString("errorExportTitle"), JOptionPane.PLAIN_MESSAGE); // and change indicator exportOk = false; } // // now that we've created our xml-document, we can // export it to a file // try { // show status text msgLabel.setText(resourceMap.getString("msg2")); // open the outputstream FileOutputStream fos = new FileOutputStream(filepath); // create a new XML-outputter with the pretty output format, // so the xml-file looks nicer XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); try { // save the main-export-file out.output(exportDoc, fos); // close the output stream fos.close(); } catch (IOException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); // and change indicator exportOk = false; } // if the user chose to export the keywords and authors as separate // file, do so if (!allinone) { // // first we export the keyword file // // prepare the filepath StringBuilder fp = new StringBuilder(filepath.toString()); // get position of file extension int ext = fp.lastIndexOf("."); // insert an appendix befor the file extenstion fp.insert(ext, "_keywords"); // create a new file File file_keywords = new File(fp.toString()); // open the outputstream fos = new FileOutputStream(file_keywords); // create a new XML-outputter with the pretty output format, // so the xml-file looks nicer out = new XMLOutputter(Format.getPrettyFormat()); try { // save the main-export-file out.output(dataObj.getKeywordData(), fos); // close the output stream fos.close(); } catch (IOException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); // and change indicator exportOk = false; } // // now we export the author file // // prepare the filepath fp = new StringBuilder(filepath.toString()); // get position of file extension ext = fp.lastIndexOf("."); // insert an appendix befor the file extenstion fp.insert(ext, "_authors"); // create a new file File file_authors = new File(fp.toString()); // open the outputstream fos = new FileOutputStream(file_authors); // create a new XML-outputter with the pretty output format, // so the xml-file looks nicer out = new XMLOutputter(Format.getPrettyFormat()); try { // save the main-export-file out.output(dataObj.getAuthorData(), fos); // close the output stream fos.close(); } catch (IOException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); // and change indicator exportOk = false; } } } catch (FileNotFoundException e) { // log error-message Constants.zknlogger.log(Level.WARNING, e.getLocalizedMessage()); // show warning message JOptionPane.showMessageDialog(null, resourceMap.getString("errorExportMsg"), resourceMap.getString("errorExportTitle"), JOptionPane.PLAIN_MESSAGE); // and change indicator exportOk = false; } catch (SecurityException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); // show warning message JOptionPane.showMessageDialog(null, resourceMap.getString("errorNoAccessMsg"), resourceMap.getString("errorNoAccessTitle"), JOptionPane.PLAIN_MESSAGE); // and change indicator exportOk = false; } // if the user requested a bibtex-export, do this now if (exportbibtex) { // show status text msgLabel.setText(resourceMap.getString("msgBibtextExport")); // write bibtex file ExportTools.writeBibTexFile(dataObj, bibtexObj, exportentries, filepath, resourceMap); } return null; // return your result }
From source file:de.danielluedecke.zettelkasten.util.Tools.java
License:Open Source License
/** * This method returns the XML database as string. just for testing purposes. * @param dataObj//from w w w.j av a2 s . co m * @return */ public static String retrieveXMLFileAsString(Daten dataObj) { // create a new XML-outputter with the pretty output format, // so the xml-file looks nicer XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); // return XML data base as string return out.outputString(dataObj.getZknData()); }
From source file:de.danielluedecke.zettelkasten.ZettelkastenView.java
License:Open Source License
/** * //from ww w. j a v a 2 s .c om * @param exportlist * @param type */ private void exportList(LinkedList<String> exportlist, String type) { String formats = getResourceMap().getString("exportListFormat1") + "," + getResourceMap().getString("exportListFormat2") + "," + getResourceMap().getString("exportListFormat3"); if (type.equalsIgnoreCase("authors")) formats = formats + "," + getResourceMap().getString("exportListFormat4"); Object[] choice = formats.split(","); Object expo = JOptionPane.showInputDialog(getFrame(), getResourceMap().getString("exportListFormatMsg"), getResourceMap().getString("exportListFormatTitle"), JOptionPane.PLAIN_MESSAGE, null, choice, null); // check for valid return value or cancel-operation of user if (expo != null) { // convert object to string String exportformat = expo.toString(); // check for valid file extenstion if (exportformat.equalsIgnoreCase(getResourceMap().getString("exportListFormat4"))) exportformat = "bib"; // here we open a swing filechooser, in case the os ist no mac aqua File filepath = FileOperationsUtil.chooseFile(getFrame(), (settings.isMacAqua()) ? FileDialog.SAVE : JFileChooser.SAVE_DIALOG, JFileChooser.FILES_ONLY, null, null, getResourceMap().getString("exportListFormatTitle"), new String[] { "." + exportformat.toLowerCase() }, expo.toString(), settings); // if we have any valid if (filepath != null) { // init extension-string String ext = null; // retrieve fileextension, in case the user does not enter a fileextension later... if (exportformat.equals(getResourceMap().getString("exportListFormat1"))) ext = "." + getResourceMap().getString("exportListFormat1").toLowerCase(); if (exportformat.equals(getResourceMap().getString("exportListFormat2"))) ext = "." + getResourceMap().getString("exportListFormat2").toLowerCase(); if (exportformat.equals(getResourceMap().getString("exportListFormat3"))) ext = "." + getResourceMap().getString("exportListFormat3").toLowerCase(); if (exportformat.equals("bib")) ext = ".bib"; // check whether the user entered a file extension. if not, add "ext" as extension if (!filepath.getName().toLowerCase().endsWith(ext)) filepath = new File(filepath.getPath() + ext); // if file does not exist, create it - otherwise the getFilePath-method of // the settings-class would return "null" as filepath, if file doesn't exist if (!filepath.exists()) { try { filepath.createNewFile(); } catch (IOException ex) { Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); } } else { // file exists, ask user to overwrite it... int optionDocExists = JOptionPane.showConfirmDialog(getFrame(), getResourceMap().getString("askForOverwriteFileMsg"), getResourceMap().getString("askForOverwriteFileTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE); // if the user does *not* choose to overwrite, quit... if (optionDocExists != JOptionPane.YES_OPTION) return; } // create variable that indicates errors... boolean errorOccured = false; // sort list aphabetically before exporting it Collections.sort(exportlist, new Comparer()); // here startes the export of xml-data if (exportformat.equals(getResourceMap().getString("exportListFormat1"))) { // create new document Document exportfile = new Document(new Element(type)); // create list-iterator Iterator<String> i = exportlist.iterator(); // iterate exportlist while (i.hasNext()) { // create new element Element e = new Element(Daten.ELEMENT_ENTRY); // at element from the list e.setText(i.next()); // add element to the document exportfile.getRootElement().addContent(e); } // save the xml-file try { // open the outputstream FileOutputStream fos = new FileOutputStream(filepath); // create a new XML-outputter with the pretty output format, // so the xml-file looks nicer XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); try { // save the main-export-file out.output(exportfile, fos); // close the output stream fos.close(); } catch (IOException e) { // log error-message Constants.zknlogger.log(Level.SEVERE, e.getLocalizedMessage()); errorOccured = true; // show error message JOptionPane.showMessageDialog(getFrame(), getResourceMap().getString("errorSavingMsg"), getResourceMap().getString("errorSavingTitle"), JOptionPane.PLAIN_MESSAGE); } } catch (FileNotFoundException ex) { // log error-message Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); errorOccured = true; // show error message JOptionPane.showMessageDialog(getFrame(), getResourceMap().getString("errorSavingMsg"), getResourceMap().getString("errorSavingTitle"), JOptionPane.PLAIN_MESSAGE); } } else if (exportformat.equals("bib")) { ByteArrayOutputStream bout = null; OutputStream exportfile = null; try { bout = bibtex.saveFile(); // create filewriter exportfile = new FileOutputStream(filepath); // retrieve string String bibdata = bout.toString("UTF-8"); // write content exportfile.write(bibdata.getBytes(Charset.forName("UTF-8"))); } catch (FileNotFoundException ex) { // log error-message Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); errorOccured = true; } catch (IOException ex) { // log error-message Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); errorOccured = true; } finally { try { if (bout != null) bout.close(); if (exportfile != null) exportfile.close(); } catch (IOException ex) { // log error-message Constants.zknlogger.log(Level.WARNING, ex.getLocalizedMessage()); errorOccured = true; } } } else { // create stringbuilder for the final content StringBuilder finalcontent = new StringBuilder(""); // create list-iterator Iterator<String> i = exportlist.iterator(); // here startes the export of txt-data if (exportformat.equals(getResourceMap().getString("exportListFormat2"))) { // iterate exportlist and copy each list-element to the string, separated by new lines while (i.hasNext()) finalcontent.append(i.next()).append(System.getProperty("line.separator")); } // here startes the export of html-data else if (exportformat.equals(getResourceMap().getString("exportListFormat3"))) { // init html-page finalcontent.append("<html><head></head><body><ol>") .append(System.getProperty("line.separator")); // iterate exportlist and copy each list-element to the string, separated by new lines while (i.hasNext()) { // create dummy string to convert German umlauts String dummy = i.next(); // convert special chars to html dummy = dummy.replace("&", "&"); dummy = dummy.replace("\"", """); dummy = dummy.replace("", "ä"); dummy = dummy.replace("", "Ä"); dummy = dummy.replace("", "ö"); dummy = dummy.replace("", "Ö"); dummy = dummy.replace("", "ü"); dummy = dummy.replace("", "Ü"); dummy = dummy.replace("", "ß"); // append converted author to stringbuilder finalcontent.append("<li>").append(dummy).append("</li>") .append(System.getProperty("line.separator")); } // close html-page finalcontent.append(System.getProperty("line.separator")).append("</ol></body></html>"); } // init output-filewriter Writer exportfile = null; try { // create filewriter exportfile = new FileWriter(filepath); // and save file to disk exportfile.write(finalcontent.toString()); } catch (IOException ex) { // log error-message Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); errorOccured = true; // show error message JOptionPane.showMessageDialog(getFrame(), getResourceMap().getString("errorSavingMsg"), getResourceMap().getString("errorSavingTitle"), JOptionPane.PLAIN_MESSAGE); } finally { try { // finally, close filewrite if (exportfile != null) { exportfile.close(); } } catch (IOException ex) { // log error-message Constants.zknlogger.log(Level.SEVERE, ex.getLocalizedMessage()); errorOccured = true; // show error message JOptionPane.showMessageDialog(getFrame(), getResourceMap().getString("errorSavingMsg"), getResourceMap().getString("errorSavingTitle"), JOptionPane.PLAIN_MESSAGE); } } } // if an errors occured, show error-log if (errorOccured) { showErrorIcon(); } else { JOptionPane.showMessageDialog(getFrame(), getResourceMap().getString("exportOkMsg"), getResourceMap().getString("exportOkTitle"), JOptionPane.PLAIN_MESSAGE); } } } }
From source file:de.hbrs.oryx.yawl.util.YAWLUtils.java
License:Open Source License
static public String elementToString(final List<Element> list) { XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); return out.outputString(list); }
From source file:de.huberlin.german.korpling.laudatioteitool.MergeTEI.java
License:Apache License
public void merge() throws LaudatioException { try {/* w w w . j av a2 s . c om*/ if (outputFile.getParentFile() != null && !outputFile.getParentFile().exists() && !outputFile.getParentFile().mkdirs()) { throw new LaudatioException( messages.getString("COULD NOT CREATE MERGED OUTPUTFILE: I CAN'T CREATE THE DIRECTORIES")); } Namespace teiNS = Namespace.getNamespace("http://www.tei-c.org/ns/1.0"); Element root = new Element("teiCorpus", teiNS); Element documentRoot = new Element("teiCorpus", teiNS); Element preparationRoot = new Element("teiCorpus", teiNS); mergeMainCorpusHeader(root); mergeDocumentHeader(documentRoot); mergePreparationHeader(preparationRoot); root.addContent(documentRoot); documentRoot.addContent(documentRoot.getChildren().size(), preparationRoot); Document mergedDoc = new Document(root); // output the new XML XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(mergedDoc, new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")); log.info(messages.getString("WRITTEN MERGED TEI"), outputFile.getPath()); } catch (SAXException ex) { throw new LaudatioException(ex.getLocalizedMessage()); } catch (JDOMException ex) { throw new LaudatioException(ex.getLocalizedMessage()); } catch (IOException ex) { throw new LaudatioException(ex.getLocalizedMessage()); } }
From source file:de.huberlin.german.korpling.laudatioteitool.SplitTEI.java
License:Apache License
private TEIValidator.Errors extractMainCorpusHeader(Document doc) throws LaudatioException, IOException, SAXException { TEIValidator validator = corpusSchemeURL == null ? new TEICorpusValidator() : new FromURLValidator(corpusSchemeURL); Element corpusHeader = doc.getRootElement().getChild("teiHeader", null); if (corpusHeader != null) { File corpusDir = new File(outputDirectory, "CorpusHeader"); if (!corpusDir.exists() && !corpusDir.mkdir()) { throw new LaudatioException( messages.getString("COULD NOT CREATE DIRECTORY") + corpusDir.getAbsolutePath()); }//from w w w .j a va2 s . c om // create the subtree for the global corpus header Namespace teiNS = Namespace.getNamespace("http://www.tei-c.org/ns/1.0"); Element newRootForCorpus = new Element("TEI", teiNS); newRootForCorpus.addContent(corpusHeader.clone()); Document corpusDoc = new Document(newRootForCorpus); if (corpusSchemeURL == null) { corpusDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + TEICorpusValidator.DEFAULT_SCHEME_URL + "\"")); } else { corpusDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + corpusSchemeURL + "\"")); } // we need to append an empty "text" element after the header Element text = new Element("text", teiNS); text.setText(""); newRootForCorpus.addContent(text); // we work with the copy from now corpusHeader = newRootForCorpus.getChild("teiHeader", null); Preconditions.checkNotNull(corpusHeader, messages.getString("ERROR NO CORPUS TITLE GIVEN")); Preconditions.checkState("CorpusHeader".equals(corpusHeader.getAttributeValue("type"))); Preconditions.checkNotNull(corpusHeader.getChild("fileDesc", null), messages.getString("ERROR NO CORPUS TITLE GIVEN")); Preconditions.checkNotNull(corpusHeader.getChild("fileDesc", null).getChild("titleStmt", null), messages.getString("ERROR NO CORPUS TITLE GIVEN")); String title = corpusHeader.getChild("fileDesc", null).getChild("titleStmt", null) .getChildTextNormalize("title", null); Preconditions.checkNotNull(title, messages.getString("ERROR NO CORPUS TITLE GIVEN")); // save the file with the title as file name File outputFile = new File(corpusDir, title + ".xml"); XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(corpusDoc, new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")); log.info(messages.getString("WRITTEN CORPUS HEADER"), outputFile.getPath()); validator.validate(outputFile); } return validator.getErrors(); }
From source file:de.huberlin.german.korpling.laudatioteitool.SplitTEI.java
License:Apache License
private TEIValidator.Errors extractDocumentHeaders(Document doc) throws LaudatioException, IOException, SAXException { TEIValidator validator = documentSchemeURL == null ? new TEIDocumentValidator() : new FromURLValidator(documentSchemeURL); File documentDir = new File(outputDirectory, "DocumentHeader"); if (!documentDir.exists() && !documentDir.mkdir()) { throw new LaudatioException( messages.getString("COULD NOT CREATE DIRECTORY") + documentDir.getAbsolutePath()); }/*from w ww . ja va 2s.co m*/ Element documentRoot = Preconditions.checkNotNull(doc.getRootElement().getChild("teiCorpus", null)); for (Element docHeader : documentRoot.getChildren("teiHeader", null)) { Preconditions.checkState("DocumentHeader".equals(docHeader.getAttributeValue("type"))); // create the subtree for the global corpus header Namespace teiNS = Namespace.getNamespace("http://www.tei-c.org/ns/1.0"); Element tei = new Element("TEI", teiNS); tei.addContent(docHeader.clone()); Document newDoc = new Document(tei); if (documentSchemeURL == null) { newDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + TEIDocumentValidator.DEFAULT_SCHEME_URL + "\"")); } else { newDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + documentSchemeURL + "\"")); } // we need to append an empty "text" element after the header Element text = new Element("text", teiNS); text.setText(""); tei.addContent(text); Element fileDesc = Preconditions .checkNotNull(tei.getChild("teiHeader", null).getChild("fileDesc", null)); String outName = UUID.randomUUID().toString(); String id = fileDesc.getAttributeValue("id", Namespace.XML_NAMESPACE); if (id != null) { outName = id; } else { Element titleStmt = Preconditions.checkNotNull(fileDesc.getChild("titleStmt", null)); String title = titleStmt.getChildText("title", null); if (title != null) { outName = title; } } File outputFile = new File(documentDir, outName + ".xml"); XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(newDoc, new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")); log.info(messages.getString("WRITTEN DOCUMENT HEADER"), outputFile.getPath()); validator.validate(outputFile); } return validator.getErrors(); }
From source file:de.huberlin.german.korpling.laudatioteitool.SplitTEI.java
License:Apache License
private TEIValidator.Errors extractPreparationSteps(Document doc) throws LaudatioException, IOException, SAXException { TEIValidator validator = preparationSchemeURL == null ? new TEIPreparationValidator() : new FromURLValidator(preparationSchemeURL); Multiset<String> knownPreparationTitles = HashMultiset.create(); File documentDir = new File(outputDirectory, "PreparationHeader"); if (!documentDir.exists() && !documentDir.mkdir()) { throw new LaudatioException( messages.getString("COULD NOT CREATE DIRECTORY") + documentDir.getAbsolutePath()); }// w w w.j a v a 2 s. c o m Preconditions.checkNotNull(doc.getRootElement().getChild("teiCorpus", null)); Element preparationRoot = Preconditions .checkNotNull(doc.getRootElement().getChild("teiCorpus", null).getChild("teiCorpus", null)); for (Element preparationHeader : preparationRoot.getChildren("teiHeader", null)) { Preconditions.checkState("PreparationHeader".equals(preparationHeader.getAttributeValue("type"))); // create the subtree for the global corpus header Namespace teiNS = Namespace.getNamespace("http://www.tei-c.org/ns/1.0"); Element tei = new Element("TEI", teiNS); tei.addContent(preparationHeader.clone()); Document newDoc = new Document(tei); if (preparationSchemeURL == null) { newDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + TEIPreparationValidator.DEFAULT_SCHEME_URL + "\"")); } else { newDoc.addContent(0, new ProcessingInstruction("xml-model", "href=\"" + preparationSchemeURL + "\"")); } // we need to append an empty "text" element after the header Element text = new Element("text", teiNS); text.setText(""); tei.addContent(text); Element fileDesc = Preconditions .checkNotNull(tei.getChild("teiHeader", null).getChild("fileDesc", null)); String outName = UUID.randomUUID().toString(); Element titleStmt = Preconditions.checkNotNull(fileDesc.getChild("titleStmt", null)); Element title = Preconditions.checkNotNull(titleStmt.getChild("title", null)); String corresp = title.getAttributeValue("corresp"); if (corresp != null) { if (knownPreparationTitles.contains(corresp)) { knownPreparationTitles.add(corresp); outName = corresp + "_" + knownPreparationTitles.count(corresp); log.warn(messages.getString("MORE THAN ONE PREPARATION HEADER"), corresp); } else { outName = corresp; knownPreparationTitles.add(corresp); } } File outputFile = new File(documentDir, outName + ".xml"); XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat()); xmlOut.output(newDoc, new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8")); log.info(messages.getString("WRITTEN PREPARATION HEADER"), outputFile.getPath()); validator.validate(outputFile); } return validator.getErrors(); }
From source file:de.ing_poetter.binview.BinaryFormat.java
License:Open Source License
public void saveToFile(final File f) throws IOException { final Element root = new Element(ROOT_ELEMENT_NAME); for (int i = 0; i < Variables.size(); i++) { final Variable v = Variables.get(i); final Element res = v.save(); root.addContent(res);/*from www.j ava 2 s. c o m*/ } final Document doc = new Document(root); final XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat()); final FileOutputStream bout = new FileOutputStream(f); xout.output(doc, bout); bout.flush(); bout.close(); }
From source file:de.knewcleus.openradar.gui.flightplan.FlightPlanExchangeManager.java
License:Open Source License
private String buildXml(FlightPlanData fpd) { Document doc = new Document(); Element root = new Element("flightplanList"); doc.addContent(root);/*from w w w. j av a 2s . c o m*/ try { root.setAttribute("version", "1.0"); Element elementFp = FpXml_1_0.createXml(fpd); if (elementFp != null) { root.addContent(elementFp); } } catch (Exception ex) { log.error("Problem to create flightplan...", ex); } StringWriter sw = new StringWriter(); try { // XMLOutputter outputter = new XMLOutputter(Format.getCompactFormat()); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); sw = new StringWriter(); outputter.output(doc, sw); } catch (Exception e) { log.error("Problem to create XML output...", e); } return sw.toString(); }