List of usage examples for org.jdom2.output XMLOutputter XMLOutputter
public XMLOutputter(XMLOutputProcessor processor)
XMLOutputter
with the specified XMLOutputProcessor. From source file:json.JSONConverter.java
License:Apache License
/** * . Gives a string representation of the object * //from w ww . j ava2 s .co m * @param format * uses prettyFormat if format is 2 * @return String representation of the object */ public final String toString(int format) { XMLOutputter sortie; if (format == 2) { sortie = new XMLOutputter(Format.getPrettyFormat()); } else { sortie = new XMLOutputter(); } return sortie.outputString(document); }
From source file:lu.list.itis.dkd.aig.util.DocumentConverter.java
License:Apache License
/** * Method for converting a {@link Document} instance into its XML * {@link String} representation.// ww w .j a v a 2s. c o m * * @param document * The {@link Document} instance to convert. * @return The {@link String} representation of the document using an * {@link XMLOutputter} and setting {@link Format} to pretty print. */ @SuppressWarnings("null") public static String convertDocumentToString(final Document document) { final XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); return outputter.outputString(document); }
From source file:main.GenerateHTML.java
License:Open Source License
/** * /*from w ww. ja v a 2 s .c om*/ * @param inName * @throws IOException */ static void printHTMLFrame(String inName) throws IOException { Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true); XMLOutputter out = new XMLOutputter(expanded); Element element = addHeader("Sources") .addContent(new Element("frameset").setAttribute("id", "mainframe").setAttribute("cols", "20%, 80%") .addContent(new Element("frameset").setAttribute("id", "mainframe") .setAttribute("rows", "20%, 50%, 30%") .addContent(new Element("frame").setAttribute("name", "tags").setAttribute("src", FileUtils.getRelTagListeName())) .addContent(new Element("frame").setAttribute("name", "source").setAttribute("src", FileUtils.getRelNilName())) .addContent(new Element("frame").setAttribute("name", "target").setAttribute("src", FileUtils.getRelNilName()))) .addContent(new Element("frameset").setAttribute("id", "mainframe") .setAttribute("rows", "50%, 50%") .addContent(new Element("frame").setAttribute("name", "doku").setAttribute("src", FileUtils.getRelDxygeDokuName())) .addContent(new Element("frame").setAttribute("name", "details").setAttribute("src", FileUtils.getRelNilName())))); outFile(inName, out.outputString(element)); }
From source file:main.GenerateHTML.java
License:Open Source License
/** * //from ww w . j ava 2s. c o m * * @throws IOException */ static void printHTMLNil() throws IOException { Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true); XMLOutputter out = new XMLOutputter(expanded); Element element = new Element("html").addContent(new Element("head")) .addContent(new Element("body").addContent(new Element("p").setText("Leer"))); outFile(FileUtils.getNilName(), out.outputString(element)); }
From source file:main.GenerateHTML.java
License:Open Source License
/** * // w w w .j a v a2 s . c o m * @param listeSource * @param listeTyp * @param nodeLinkListe * @param inNodeTag * @throws IOException */ static void printHTMLSource(List<NodeSource> listeSource, List<NodeTyp> listeTyp, List<NodeTarget> nodeLinkListe, NodeTag inNodeTag) throws IOException { Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true); XMLOutputter out = new XMLOutputter(expanded); Element element = new Element("html").addContent(new Element("title").setText("Sources")); Element body = new Element("body"); element.addContent(body); int count = 0; for (NodeSource node : listeSource) { if (node.getName().equals(inNodeTag.getName())) { count++; } } if (count == 0) { body.addContent(new Element("p").setText(String.format("No reference for: %s", inNodeTag.getName()))); } else { for (NodeSource node : listeSource) { if (node.getName().equals(inNodeTag.getName())) { body.addContent(new Element("p").addContent(new Element("a") .setText(String.format("%s %s", node.getName(), node.getNummer())) .setAttribute("href", FileUtils.getRelLinkName(node)).setAttribute("target", "target") .setAttribute("title", "Beschreibung der Klasse").setAttribute("onclick", String.format("top.doku.location='%s'; return true;", node.getFileName())))); GenerateHTML.printHTMLLink(node, listeTyp, nodeLinkListe); } } } outFile(FileUtils.getSourceName(inNodeTag), out.outputString(element)); }
From source file:main.GenerateHTML.java
License:Open Source License
/** * /* w ww. j ava2 s . com*/ * @param liste * @param listeSource * @param listeTyp * @param listeLink * @throws IOException */ static void printHTMLTags(List<NodeTag> liste, List<NodeSource> listeSource, List<NodeTyp> listeTyp, List<NodeTarget> listeLink) throws IOException { Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true); XMLOutputter out = new XMLOutputter(expanded); Element element = addHeader("Sources"); Element body = new Element("body"); element.addContent(body); for (NodeTag nodeTag : liste) { Element link = new Element("p").setText(String.format("%s", nodeTag.getName())); body.addContent(link); link.addContent(new Element("a").setText(nodeTag.getName()) .setAttribute("href", FileUtils.getRelSourceName(nodeTag)).setAttribute("target", "source")); GenerateHTML.printHTMLSource(listeSource, listeTyp, listeLink, nodeTag); } outFile(FileUtils.getTagListeName(), out.outputString(element)); }
From source file:main.GenerateHTML.java
License:Open Source License
/** * //w w w . j a v a 2 s .co m * @param nodeQuelle * @param listeTyp * @param nodeLinkList * @throws IOException */ static void printHTMLLink(NodeSource nodeQuelle, List<NodeTyp> listeTyp, List<NodeTarget> nodeLinkList) throws IOException { Format expanded = Format.getPrettyFormat().setExpandEmptyElements(true); XMLOutputter out = new XMLOutputter(expanded); Element element = addHeader("Sources"); Element body = new Element("body").addContent(new Element("h3") .setText(String.format("Links: %s %s", nodeQuelle.getName(), nodeQuelle.getNummer()))); element.addContent(body); // Count number of referencwes int count = 0; for (NodeTyp node : listeTyp) { for (NodeTarget nodeLink : nodeLinkList) { if (nodeLink.getTyp().equals(node.getName())) { if (nodeQuelle.getName().equals(nodeLink.getName()) & nodeQuelle.getNummer().equals(nodeLink.getNummer())) { count++; } } } } if (count == 0) { body.addContent(new Element("p").setText("No Links")); } else { for (NodeTyp node : listeTyp) { int countLink = 0; for (NodeTarget nodeLink : nodeLinkList) { if (nodeLink.getTyp().equals(node.getName())) { if (nodeQuelle.getName().equals(nodeLink.getName()) & nodeQuelle.getNummer().equals(nodeLink.getNummer())) { countLink++; } } } if (countLink == 0) { body.addContent(new Element("p").setText(String.format("%s: no Element", node.getName()))); } else { for (NodeTarget nodeLink : nodeLinkList) { if (nodeLink.getTyp().equals(node.getName())) { if (nodeQuelle.getName().equals(nodeLink.getName()) & nodeQuelle.getNummer().equals(nodeLink.getNummer())) { body.addContent(new Element("p").setText(node.getName()) .addContent(new Element("a").setText(nodeLink.getName()) .setAttribute("href", nodeLink.getFileName()) .setAttribute("title", "Beschreibung der Klasse") .setAttribute("target", "details"))); } } } } } } outFile(FileUtils.getLinkName(nodeQuelle), out.outputString(element)); }
From source file:main.Var.java
License:Open Source License
private static void XMLSave(String ruta) { try {//from www . j a v a 2s.co m Element ele; SAXBuilder builder = new SAXBuilder(); File xmlFile = new File(ruta); Document document = (Document) builder.build(xmlFile); Element config = document.getRootElement(); Element conexion = config.getChild("conexion"); ele = conexion.getChild("db-host"); ele.setText(con.getDireccion()); ele = conexion.getChild("db-port"); ele.setText(con.getPuerto()); ele = conexion.getChild("db-username"); ele.setText(con.getUsuario()); ele = conexion.getChild("db-password"); ele.setText(con.getPass()); Element ftp = config.getChild("ftp"); ele = ftp.getChild("ftp-host"); ele.setText(conFtp.getHost()); ele = ftp.getChild("ftp-port"); ele.setText(Integer.toString(conFtp.getPort())); ele = ftp.getChild("ftp-user"); ele.setText(conFtp.getUser()); ele = ftp.getChild("ftp-pass"); ele.setText(conFtp.getPass()); Element admin = config.getChild("modoAdmin"); ele = admin.getChild("activo"); if (modoAdmin) { ele.setText("true"); } else { ele.setText("false"); } ele = admin.getChild("password"); ele.setText(passwordAdmin); ele = admin.getChild("query-limit"); ele.setText(queryLimit); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); try { outputter.output(document, new FileOutputStream(configFile)); } catch (Exception e) { e.getMessage(); } } catch (JDOMException | IOException ex) { Logger.getLogger(Var.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:model.advertisement.AbstractAdvertisement.java
License:Open Source License
@Override /**/*from w ww.j av a 2 s . c om*/ * Return a string, XML-Formatted, representing this instance. */ public String toString() { org.jdom2.Element document = this.getRootElement(); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); String xmlString = outputter.outputString(document); return xmlString; }
From source file:model.advertisement.AbstractAdvertisement.java
License:Open Source License
public String getDocumentString() { org.jdom2.Document document = this.getDocument(); XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); String xmlString = outputter.outputString(document); return xmlString; }