List of usage examples for org.jdom2.output XMLOutputter XMLOutputter
public XMLOutputter()
XMLOutputter
with a default Format and XMLOutputProcessor . From source file:ca.nrc.cadc.dali.tables.votable.VOTableWriter.java
License:Open Source License
/** * Write the Throwable to a VOTable, creating an INFO element with * name="QUERY_STATUS" value="ERROR" and setting the stacktrace as * the INFO text./*from w w w . j a v a2 s . c om*/ * * @param thrown Throwable to write. * @param output OutputStream to write to. * @throws IOException if problem writing to the stream. */ public void write(Throwable thrown, OutputStream output) throws IOException { Document document = createDocument(); Element root = document.getRootElement(); Namespace namespace = root.getNamespace(); // Create the RESOURCE element and add to the VOTABLE element. Element resource = new Element("RESOURCE", namespace); resource.setAttribute("type", "results"); root.addContent(resource); // Create the INFO element and add to the RESOURCE element. Element info = new Element("INFO", namespace); info.setAttribute("name", "QUERY_STATUS"); info.setAttribute("value", "ERROR"); info.setText(getThrownExceptions(thrown)); resource.addContent(info); // Write out the VOTABLE. XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(org.jdom2.output.Format.getPrettyFormat()); outputter.output(document, output); }
From source file:ca.nrc.cadc.uws.JobListWriter.java
License:Open Source License
/** * Write to root Element to a writer.//from w w w .ja v a2 s. co m * * @param root Root Element to write. * @param writer Writer to write to. * @throws IOException if the writer fails to write. */ protected void writeDocument(Element root, Writer writer) throws IOException { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); Document document = new Document(root); outputter.output(document, writer); }
From source file:ca.nrc.cadc.uws.JobListWriter.java
License:Open Source License
/** * Write the job list to our streaming xml writer. * * @param jobs/*from w w w. java 2s.c o m*/ * @param writer Writer to write to. * @throws IOException if the writer fails to write. */ public void write(Iterator<JobRef> jobs, Writer writer) throws IOException { Element root = getRootElement(jobs); XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); Document document = new Document(root); outputter.output(document, writer); }
From source file:ca.nrc.cadc.uws.JobReader.java
License:Open Source License
private JobInfo parseJobInfo(Document doc) { JobInfo rtn = null;/*w w w. j ava2 s . c om*/ Element root = doc.getRootElement(); Element e = root.getChild(JobAttribute.JOB_INFO.getAttributeName(), UWS.NS); if (e != null) { log.debug("found jobInfo element"); String content = e.getText(); List children = e.getChildren(); if (content != null) content = content.trim(); if (content.length() > 0) // it was text content { rtn = new JobInfo(content, null, null); } else if (children != null) { if (children.size() == 1) { try { Element ce = (Element) children.get(0); Document jiDoc = new Document((Element) ce.detach()); XMLOutputter outputter = new XMLOutputter(); StringWriter sw = new StringWriter(); outputter.output(jiDoc, sw); sw.close(); rtn = new JobInfo(sw.toString(), null, null); } catch (IOException ex) { throw new RuntimeException("BUG while writing element to string", ex); } } } } log.debug("parseJobInfo: " + rtn); return rtn; }
From source file:ca.nrc.cadc.uws.JobWriter.java
License:Open Source License
/** * Write the job to a writer./*from w w w .ja v a 2 s . co m*/ * * @param job * @param writer Writer to write to. * @throws IOException if the writer fails to write. */ public void write(Job job, Writer writer) throws IOException { Element root = getRootElement(job); XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); Document document = new Document(root); outputter.output(document, writer); }
From source file:ca.nrc.cadc.uws.web.restlet.representation.JDOMRepresentation.java
License:Open Source License
/** * Write the Document to the OutputStream. * /*from ww w .j a va 2s .c o m*/ * @param out The OutputStream to write to. * @throws IOException if there is a problem writing the Document. */ @Override public void write(OutputStream out) throws IOException { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); outputter.output(document, out); }
From source file:ca.nrc.cadc.vodml.VOModelWriter.java
License:Open Source License
public void write(Document doc, Writer out) throws IOException { XMLOutputter outputter = new XMLOutputter(); if (prettyPrint) { outputter.setFormat(Format.getPrettyFormat()); } else {/*from ww w . j a v a 2 s . c om*/ outputter.setFormat(Format.getCompactFormat()); } outputter.output(doc, out); }
From source file:ca.nrc.cadc.vos.client.VOSClientUtil.java
License:Open Source License
public static String xmlString(Document doc) { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); return outputter.outputString(doc); }
From source file:ca.nrc.cadc.vos.server.RssView.java
License:Open Source License
/** * Write to root Element to a writer.// w w w .j av a 2 s .c om * * @param root Root Element to write. * @param writer Writer to write to. * @throws IOException if the writer fails to write. */ protected void write(Element root, Writer writer) throws IOException { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); Document document = new Document(); root.detach(); document.setRootElement(root); outputter.output(document, writer); }
From source file:ca.nrc.cadc.vos.TransferWriter.java
License:Open Source License
/** * Write to root Element to a writer./*w ww . ja v a 2 s.c o m*/ * * @param root Root Element to write. * @param writer Writer to write to. * @throws IOException if the writer fails to write. */ @SuppressWarnings("unchecked") protected void write(Element root, Writer writer) throws IOException { XMLOutputter outputter = new XMLOutputter(); outputter.setFormat(Format.getPrettyFormat()); Document document = new Document(root); outputter.output(document, writer); }