List of usage examples for org.jdom2.output XMLOutputter outputString
public final String outputString(EntityRef entity)
From source file:main.GenerateHTML.java
License:Open Source License
/** * /*from ww w . j a va 2 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 ww . jav a 2s .c o 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:model.advertisement.AbstractAdvertisement.java
License:Open Source License
@Override /**/*from ww w . j a va 2 s. co m*/ * 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; }
From source file:model.data.RendezVousIp.java
License:Open Source License
@Override protected void putValues() { XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); addValue("ips", out.outputString(ips)); }
From source file:net.instantcom.mm7.MM7Error.java
License:Open Source License
@Override public void load(Element element) { Element body = element.getChild("Body", MM7Message.ENVELOPE); Element e = (Element) body.getChildren().get(0); this.faultCode = e.getChildTextTrim("faultcode"); this.faultMessage = e.getChildTextTrim("faultstring"); try {//w w w . j ava 2 s .c om Element detail; if (element.getNamespace("") != null) { detail = (Element) e.getChild("detail", element.getNamespace("")).getChildren().get(0); } else { detail = (Element) e.getChild("detail").getChildren().get(0); } String message = detail.getName(); // Instantiate correct status type Class<?> clazz = Class.forName("net.instantcom.mm7." + message); this.response = (MM7Response) clazz.newInstance(); this.response.load(element); } catch (Throwable t) { // Ignored XMLOutputter outp = new XMLOutputter(); String s = outp.outputString(element); System.err.println("Failed to instantiate a correct response type" + s); t.printStackTrace(); } }
From source file:nl.nn.adapterframework.util.XmlBuilder.java
License:Apache License
public String toXML(boolean xmlHeader) { Document document = new Document(element.detach()); XMLOutputter xmlOutputter = new XMLOutputter(); xmlOutputter.setFormat(Format.getPrettyFormat().setOmitDeclaration(!xmlHeader)); return xmlOutputter.outputString(document); }
From source file:org.apache.marmotta.ldpath.model.functions.xml.XPathFunction.java
License:Apache License
private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException { LinkedList<String> result = new LinkedList<String>(); try {/*from w w w. j av a2 s. co m*/ Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in)); XMLOutputter out = new XMLOutputter(); for (String xp : xpaths) { XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content()); for (Content node : xpath.evaluate(doc)) { if (node instanceof Element) { result.add(out.outputString((Element) node)); } else if (node instanceof Text) { result.add(out.outputString((Text) node)); } } } return result; } catch (JDOMException xpe) { throw new IllegalArgumentException("error while processing xpath expressions: '" + xpaths + "'", xpe); } }
From source file:org.apache.wiki.plugin.IndexPlugin.java
License:Apache License
/** * {@inheritDoc}//from www . java 2s . c o m */ public String execute(WikiContext context, Map<String, String> params) throws PluginException { String include = params.get(PARAM_INCLUDE); String exclude = params.get(PARAM_EXCLUDE); Element masterDiv = getElement("div", "index"); Element indexDiv = getElement("div", "header"); masterDiv.addContent(indexDiv); try { List<String> pages = listPages(context, include, exclude); context.getEngine().getPageSorter().sort(pages); char initialChar = ' '; Element currentDiv = new Element("div", xmlns_XHTML); for (String name : pages) { if (name.charAt(0) != initialChar) { if (initialChar != ' ') { indexDiv.addContent(" - "); } initialChar = name.charAt(0); masterDiv.addContent(makeHeader(String.valueOf(initialChar))); currentDiv = getElement("div", "body"); masterDiv.addContent(currentDiv); indexDiv.addContent(getLink("#" + initialChar, String.valueOf(initialChar))); } else { currentDiv.addContent(", "); } currentDiv.addContent(getLink(context.getURL(WikiContext.VIEW, name), name)); } } catch (ProviderException e) { log.warn("could not load page index", e); throw new PluginException(e.getMessage()); } // serialize to raw format string (no changes to whitespace) XMLOutputter out = new XMLOutputter(Format.getRawFormat()); return out.outputString(masterDiv); }
From source file:org.apache.wiki.util.XhtmlUtil.java
License:Apache License
/** * Serializes the Element to a String. Allows to use a custom <tt>format</tt>. * /*from w w w . jav a 2 s.c om*/ * @param element the element to serialize. * @param format custom <tt>format</tt> used to serialize the Element. * @return the serialized Element. */ public static String serialize(Element element, Format format) { XMLOutputter out = new XMLOutputter(format); return out.outputString(element); }