org.jdom.output.XMLOutputter

Here are the examples of the java api class org.jdom.output.XMLOutputter taken from open source projects.

1. DataManagementToolTest#prettyXmlPrint()

Project: continuum
File: DataManagementToolTest.java
public String prettyXmlPrint(String xml) throws Exception {
    SAXBuilder saxBuilder = new SAXBuilder();
    Document document = saxBuilder.build(new StringReader(xml));
    XMLOutputter outp = new XMLOutputter();
    outp.setFormat(Format.getPrettyFormat());
    StringWriter sw = new StringWriter();
    outp.output(document, sw);
    return sw.getBuffer().toString();
}

2. ClusterMapper#writeCluster()

Project: voldemort
File: ClusterMapper.java
public String writeCluster(Cluster cluster) {
    Document doc = new Document(new Element(CLUSTER_ELMT));
    doc.getRootElement().addContent(new Element(CLUSTER_NAME_ELMT).setText(cluster.getName()));
    boolean displayZones = cluster.getZones().size() > 1;
    if (displayZones) {
        for (Zone n : cluster.getZones()) doc.getRootElement().addContent(mapZone(n));
    }
    for (Node n : cluster.getNodes()) doc.getRootElement().addContent(mapServer(n, displayZones));
    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    return serializer.outputString(doc.getRootElement());
}

3. RestUtils#constructSerializerInfoXml()

Project: voldemort
File: RestUtils.java
/**
     * Given a storedefinition, constructs the xml string to be sent out in
     * response to a "schemata" fetch request
     * 
     * @param storeDefinition
     * @return serialized store definition
     */
public static String constructSerializerInfoXml(StoreDefinition storeDefinition) {
    Element store = new Element(StoreDefinitionsMapper.STORE_ELMT);
    store.addContent(new Element(StoreDefinitionsMapper.STORE_NAME_ELMT).setText(storeDefinition.getName()));
    Element keySerializer = new Element(StoreDefinitionsMapper.STORE_KEY_SERIALIZER_ELMT);
    StoreDefinitionsMapper.addSerializer(keySerializer, storeDefinition.getKeySerializer());
    store.addContent(keySerializer);
    Element valueSerializer = new Element(StoreDefinitionsMapper.STORE_VALUE_SERIALIZER_ELMT);
    StoreDefinitionsMapper.addSerializer(valueSerializer, storeDefinition.getValueSerializer());
    store.addContent(valueSerializer);
    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    return serializer.outputString(store);
}

4. OvalFileAggregator#finish()

Project: spacewalk
File: OvalFileAggregator.java
/**
     * Finalizes processing and builds the aggregated document
     * @param prettyPrint pretty print XML or not
     * @return XML in string form
     * @throws IOException document output failed
     */
public String finish(boolean prettyPrint) throws IOException {
    if (!isFinished && !isEmpty()) {
        buildDocument();
        isFinished = true;
    }
    if (isEmpty()) {
        return "";
    }
    XMLOutputter out = new XMLOutputter();
    if (prettyPrint) {
        out.setFormat(Format.getPrettyFormat());
    } else {
        out.setFormat(Format.getCompactFormat());
    }
    StringWriter buffer = new StringWriter();
    out.output(aggregate, buffer);
    String retval = buffer.toString();
    retval = retval.replaceAll(" xmlns:oval=\"removeme\"", "");
    return retval.replaceAll(" xmlns:redhat=\"removeme\"", "");
}

5. JDOMUtil#createOutputter()

Project: intellij-community
File: JDOMUtil.java
@NotNull
public static XMLOutputter createOutputter(String lineSeparator) {
    XMLOutputter xmlOutputter = new MyXMLOutputter();
    Format format = Format.getCompactFormat().setIndent("  ").setTextMode(Format.TextMode.TRIM).setEncoding(CharsetToolkit.UTF8).setOmitEncoding(false).setOmitDeclaration(false).setLineSeparator(lineSeparator);
    xmlOutputter.setFormat(format);
    return xmlOutputter;
}

6. JDOMUtil#createOutputter()

Project: consulo
File: JDOMUtil.java
@NotNull
public static XMLOutputter createOutputter(String lineSeparator) {
    XMLOutputter xmlOutputter = new MyXMLOutputter();
    Format format = Format.getCompactFormat().setIndent("  ").setTextMode(Format.TextMode.TRIM).setEncoding(CharsetToolkit.UTF8).setOmitEncoding(false).setOmitDeclaration(false).setLineSeparator(lineSeparator);
    xmlOutputter.setFormat(format);
    return xmlOutputter;
}

7. XMLUtilities#createMobyDataElementWrapper()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param xml
	 * @param queryID
	 * @return
	 * @throws MobyException
	 */
public static String createMobyDataElementWrapper(String xml, String queryID) throws MobyException {
    if (xml == null)
        return null;
    Element serviceNotes = getServiceNotes(getDOMDocument(xml).getRootElement());
    Element element = createMobyDataElementWrapper(getDOMDocument(xml).getRootElement(), queryID, serviceNotes);
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return (element == null ? null : outputter.outputString(element));
}

8. XMLUtilities#getSingleInvokationsFromMultipleInvokations()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param xml
	 *            the message to extract the invocation messages from
	 * @return an array of String objects each representing a distinct BioMOBY
	 *         invocation message.
	 * @throws MobyException
	 *             if the moby message is invalid or if the xml is syntatically
	 *             invalid.
	 */
public static String[] getSingleInvokationsFromMultipleInvokations(String xml) throws MobyException {
    Element[] elements = getSingleInvokationsFromMultipleInvokations(getDOMDocument(xml).getRootElement());
    String[] strings = new String[elements.length];
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int i = 0; i < elements.length; i++) {
        strings[i] = output.outputString(new Document(elements[i]));
    }
    return strings;
}

9. XMLUtilities#getWrappedSimplesFromCollection()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 *            the name of the collection to extract the simples from.
	 * @param xml
	 *            the XML to extract from
	 * @return an array of String objects that represent the simples, with the
	 *         name of the collection
	 * @throws MobyException
	 *             if the collection doesnt exist or the xml is invalid
	 */
public static String[] getWrappedSimplesFromCollection(String name, String xml) throws MobyException {
    Element[] elements = getWrappedSimplesFromCollection(name, getDOMDocument(xml).getRootElement());
    String[] strings = new String[elements.length];
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int i = 0; i < elements.length; i++) {
        try {
            strings[i] = output.outputString(elements[i]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unknown error occured while creating String[]." + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

10. XMLUtilities#getSimplesFromCollection()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param xml
	 *            the XML to extract from
	 * @return an array of String objects that represent the simples
	 * @throws MobyException
	 */
public static String[] getSimplesFromCollection(String xml) throws MobyException {
    Element[] elements = getSimplesFromCollection(getDOMDocument(xml).getRootElement());
    String[] strings = new String[elements.length];
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int i = 0; i < elements.length; i++) {
        try {
            strings[i] = output.outputString(elements[i]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unknown error occured while creating String[]." + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

11. XMLUtilities#getAllSimplesByArticleName()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 *            the name of the simples that you would like to extract. The
	 *            name can be collection name as well. This method extracts
	 *            simples from all invocation messages.
	 * @param xml
	 *            the xml to extract the simples from
	 * @return a String[] of Simples that you are looking for, taken from
	 *         collections with your search name as well as simple elements with
	 *         the search name
	 * @throws MobyException
	 *             if there is a problem with the BioMOBY message
	 */
public static String[] getAllSimplesByArticleName(String name, String xml) throws MobyException {
    Element[] elements = getAllSimplesByArticleName(name, getDOMDocument(xml).getRootElement());
    String[] strings = new String[elements.length];
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int i = 0; i < elements.length; i++) {
        try {
            strings[i] = output.outputString(elements[i]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unknown error occured while creating String[]." + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

12. XMLUtilities#getSimplesFromCollection()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 *            the name of the collection to extract the simples from.
	 * @param xml
	 *            the XML to extract from
	 * @return an array of String objects that represent the simples
	 * @throws MobyException
	 */
public static String[] getSimplesFromCollection(String name, String xml) throws MobyException {
    Element[] elements = getSimplesFromCollection(name, getDOMDocument(xml).getRootElement());
    String[] strings = new String[elements.length];
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int i = 0; i < elements.length; i++) {
        try {
            strings[i] = output.outputString(elements[i]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unknown error occured while creating String[]." + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

13. XMLUtilities#getSimple()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 * This method assumes a single invocation was passed to it
	 * <p>
	 *
	 * @param name
	 *            the article name of the simple that you are looking for
	 * @param xml
	 *            the xml that you want to query
	 * @return a String object that represent the simple found.
	 * @throws MobyException
	 *             if no simple was found given the article name and/or data
	 *             type or if the xml was not valid moby xml or if an unexpected
	 *             error occurs.
	 */
public static String getSimple(String name, String xml) throws MobyException {
    Element element = getDOMDocument(xml).getRootElement();
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    Element simples = getSimple(name, element);
    if (simples != null) {
        try {
            return outputter.outputString(simples);
        } catch (Exception e) {
            throw new MobyException(newline + "Unexpected error occured while creating String[]:" + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    throw new MobyException(newline + "The simple named '" + name + "' was not found in the xml:" + newline + xml + newline);
}

14. XMLUtilities#getListOfCollections()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param message
	 *            the String to extract the list of collections from and assumes
	 *            that you are passing in a single invocation message.
	 * @return an array of Strings representing all of the fully 'wrapped'
	 *         collections in the message.
	 * @throws MobyException
	 *             if the the element contains an invalid BioMOBY message
	 */
public static String[] getListOfCollections(String message) throws MobyException {
    Element element = getDOMDocument(message).getRootElement();
    Element[] elements = getListOfCollections(element);
    String[] strings = new String[elements.length];
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int count = 0; count < elements.length; count++) {
        try {
            strings[count] = outputter.outputString(elements[count]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unexpected error occured while creating String[]:" + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

15. XMLUtilities#getListOfSimples()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param message
	 *            the String of xml to extract the list of simples from. This
	 *            method assumes that you are passing in a single invokation and
	 *            that you wish to extract the Simples not contained in any
	 *            collections. This method also maintains any past queryIDs.
	 * @return an array of Strings that represent fully 'wrapped' simples.
	 * @throws MobyException
	 *             if the String doesnt contain a structurally valid Moby
	 *             message structure or if an unexpected error occurs
	 */
public static String[] getListOfSimples(String message) throws MobyException {
    Element element = getDOMDocument(message).getRootElement();
    Element[] elements = getListOfSimples(element);
    String[] strings = new String[elements.length];
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    for (int count = 0; count < elements.length; count++) {
        try {
            strings[count] = outputter.outputString(elements[count]);
        } catch (Exception e) {
            throw new MobyException(newline + "Unexpected error occured while creating String[]:" + newline + Utils.format(e.getLocalizedMessage(), 3));
        }
    }
    return strings;
}

16. XMLOutputSplitter#extractDataListFromChildList()

Project: incubator-taverna-common-activities
File: XMLOutputSplitter.java
private List<String> extractDataListFromChildList(List<Element> children, boolean isXMLContent) {
    List<String> result = new ArrayList<String>();
    XMLOutputter outputter = new XMLOutputter();
    for (Element child : children) {
        if (!isXMLContent) {
            result.add(child.getTextTrim());
        } else {
            result.add(outputter.outputString(child));
        }
    }
    return result;
}

17. XMLOutputSplitter#executeForArrayType()

Project: incubator-taverna-common-activities
File: XMLOutputSplitter.java
private void executeForArrayType(Map<String, Object> result, List<Element> children) {
    ArrayTypeDescriptor arrayDescriptor = (ArrayTypeDescriptor) typeDescriptor;
    List<String> values = new ArrayList<String>();
    XMLOutputter outputter = new XMLOutputter();
    boolean isInnerBaseType = arrayDescriptor.getElementType() instanceof BaseTypeDescriptor;
    if (isInnerBaseType) {
        values = extractBaseTypeArrayFromChildren(children);
    } else {
        for (Element child : children) {
            values.add(outputter.outputString(child));
        }
    }
    result.put(outputNames[0], values);
}

18. JDOMUtils#doc2String()

Project: geowave
File: JDOMUtils.java
public static String doc2String(final Document doc) {
    final StringWriter sw = new StringWriter();
    final Format format = Format.getRawFormat().setEncoding("UTF-8");
    final XMLOutputter xmlOut = new XMLOutputter(format);
    String strOutput = null;
    if (doc != null) {
        try {
            xmlOut.output(doc, sw);
            strOutput = sw.toString();
        } catch (final IOException e) {
            return null;
        }
    }
    return strOutput;
}

19. MavenJDOMWriter#write()

Project: maven-plugins
File: MavenJDOMWriter.java
// -- void write(Model, Document, OutputStreamWriter)
/**
     * Method write
     *
     * @param project
     * @param jdomFormat
     * @param writer
     * @param document
     */
public void write(Model project, Document document, Writer writer, Format jdomFormat) throws java.io.IOException {
    updateModel(project, "project", new Counter(0), document.getRootElement());
    XMLOutputter outputter = new XMLOutputter();
    outputter.setFormat(jdomFormat);
    outputter.output(document, writer);
}

20. MavenJDOMWriter#write()

Project: maven-plugins
File: MavenJDOMWriter.java
// -- void updateSite(Site, String, Counter, Element)
/**
     * Method write
     *
     * @param project
     * @param stream
     * @param document
     * @deprecated
     */
public void write(Model project, Document document, OutputStream stream) throws java.io.IOException {
    updateModel(project, "project", new Counter(0), document.getRootElement());
    XMLOutputter outputter = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent("    ").setLineSeparator(System.getProperty("line.separator"));
    outputter.setFormat(format);
    outputter.output(document, stream);
}

21. XMLOutputterTest#printElement()

Project: intellij-community
File: XMLOutputterTest.java
private String printElement(Element root) throws IOException {
    XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n");
    final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true);
    xmlOutputter.setFormat(format);
    CharArrayWriter writer = new CharArrayWriter();
    xmlOutputter.output(root, writer);
    String res = new String(writer.toCharArray());
    return res;
}

22. XMLOutputterTest#printElement()

Project: consulo
File: XMLOutputterTest.java
private String printElement(Element root) throws IOException {
    XMLOutputter xmlOutputter = JDOMUtil.createOutputter("\n");
    final Format format = xmlOutputter.getFormat().setOmitDeclaration(true).setOmitEncoding(true).setExpandEmptyElements(true);
    xmlOutputter.setFormat(format);
    CharArrayWriter writer = new CharArrayWriter();
    xmlOutputter.output(root, writer);
    String res = new String(writer.toCharArray());
    return res;
}

23. StoreDefinitionsMapper#writeStoreList()

Project: voldemort
File: StoreDefinitionsMapper.java
public String writeStoreList(List<StoreDefinition> stores) {
    Element root = new Element(STORES_ELMT);
    for (StoreDefinition def : stores) {
        if (def.isView())
            root.addContent(viewToElement(def));
        else
            root.addContent(storeToElement(def));
    }
    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    return serializer.outputString(root);
}

24. DocumentExtraction#toXmlString()

Project: Mallet
File: DocumentExtraction.java
public String toXmlString() {
    Document jdom = toXmlDocument();
    XMLOutputter outputter = new XMLOutputter();
    return outputter.outputString(jdom);
}

25. XmlFeaturesRepository#write()

Project: karaf-eik
File: XmlFeaturesRepository.java
@Override
public void write(final OutputStream out) throws IOException {
    final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
    xmlOutputter.output(document, out);
}

26. XMLTree#getText()

Project: incubator-taverna-workbench
File: XMLTree.java
public String getText() {
    if (rootElement == null)
        return "";
    XMLOutputter xo = new XMLOutputter(getPrettyFormat());
    return xo.outputString(rootElement);
}

27. XMLUtilities#createMultipleInvokations()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param xmls
	 * @return
	 * @throws MobyException
	 */
public static String createMultipleInvokations(String[] xmls) throws MobyException {
    Element[] elements = new Element[xmls.length];
    for (int i = 0; i < elements.length; i++) {
        elements[i] = getDOMDocument(xmls[i]).getRootElement();
    }
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return output.outputString(createMultipleInvokations(elements));
}

28. XMLUtilities#createServiceInput()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param elements
	 *            the fully wrapped moby simples and/or collections to wrap an
	 *            input message around
	 * @param queryID
	 *            the queryID for this input
	 * @return a fully wrapped message with an appropriate queryID and elements
	 *         added to it
	 * @throws MobyException
	 *             if an element is invalid or if the XML is syntatically
	 *             invalid.
	 */
public static String createServiceInput(String[] elements, String queryID) throws MobyException {
    Element[] element = new Element[elements.length];
    for (int i = 0; i < elements.length; i++) {
        element[i] = getDOMDocument(elements[i]).getRootElement();
    }
    XMLOutputter output = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return output.outputString(createServiceInput(element, queryID));
}

29. XMLUtilities#getWrappedCollection()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 * @param xml
	 * @return
	 * @throws MobyException
	 */
public static String getWrappedCollection(String name, String xml) throws MobyException {
    Element element = getWrappedCollection(name, getDOMDocument(xml).getRootElement());
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return outputter.outputString(element);
}

30. XMLUtilities#getWrappedSimple()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 *            the articlename of the simple that you wish to extract
	 * @param xml
	 *            the xml message
	 * @return the wrapped simple if it exists
	 * @throws MobyException
	 *             if the message is a multiple invocation message or if the xml
	 *             is syntatically invalid.
	 */
public static String getWrappedSimple(String name, String xml) throws MobyException {
    Element element = getWrappedSimple(name, getDOMDocument(xml).getRootElement());
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return outputter.outputString(element);
}

31. JDomAcceptanceTest#testMarshalsObjectToJDOM()

Project: xstream
File: JDomAcceptanceTest.java
public void testMarshalsObjectToJDOM() {
    X x = new X();
    x.anInt = 9;
    x.aStr = "zzz";
    x.innerObj = new Y();
    x.innerObj.yField = "ooo";
    String expected = "<x>\n" + "  <aStr>zzz</aStr>\n" + "  <anInt>9</anInt>\n" + "  <innerObj>\n" + "    <yField>ooo</yField>\n" + "  </innerObj>\n" + "</x>";
    JDomWriter writer = new JDomWriter();
    xstream.marshal(x, writer);
    List result = writer.getTopLevelNodes();
    assertEquals("Result list should contain exactly 1 element", 1, result.size());
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setLineSeparator("\n"));
    assertEquals(expected, outputter.outputString(result));
}

32. StoreDefinitionsMapper#writeStore()

Project: voldemort
File: StoreDefinitionsMapper.java
public String writeStore(StoreDefinition store) {
    XMLOutputter serializer = new XMLOutputter(Format.getPrettyFormat());
    if (store.isView())
        return serializer.outputString(viewToElement(store));
    else
        return serializer.outputString(storeToElement(store));
}

33. OPMLExporter#exportTo()

Project: RSSOwl
File: OPMLExporter.java
/*
   * @see org.rssowl.core.interpreter.ITypeExporter#exportTo(java.io.File,
   * java.util.Collection, java.util.Set)
   */
public void exportTo(File destination, Collection<? extends IFolderChild> elements, Set<Options> options) throws InterpreterException {
    Format format = Format.getPrettyFormat();
    format.setEncoding(UTF_8);
    XMLOutputter output = new XMLOutputter(format);
    DateFormat dateFormat = DateFormat.getDateInstance();
    Document document = new Document();
    Element root = new Element(Tag.OPML.get());
    //$NON-NLS-1$
    root.setAttribute(Attributes.VERSION.get(), "1.1");
    root.addNamespaceDeclaration(RSSOWL_NS);
    document.setRootElement(root);
    /* Head */
    Element head = new Element(Tag.HEAD.get());
    root.addContent(head);
    Element title = new Element(Tag.TITLE.get());
    title.setText(Messages.OPMLExporter_RSSOWL_SUBSCRIPTIONS);
    head.addContent(title);
    Element dateModified = new Element(Tag.DATE_MODIFIED.get());
    //$NON-NLS-1$
    dateModified.setText(new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z").format(new Date()));
    head.addContent(dateModified);
    /* Body */
    Element body = new Element(Tag.BODY.get());
    root.addContent(body);
    boolean exportPreferences = (options != null && options.contains(Options.EXPORT_PREFERENCES));
    /* Export Folder Childs */
    if (elements != null && !elements.isEmpty()) {
        Map<IFolder, Element> mapFolderToElement = new HashMap<IFolder, Element>();
        mapFolderToElement.put(null, body);
        /* Ensure that all Parent Elements exist */
        repairHierarchy(mapFolderToElement, elements, exportPreferences);
        /* Now export Elements */
        exportFolderChilds(mapFolderToElement, elements, exportPreferences, dateFormat);
    }
    /* Export Labels */
    if (options != null && options.contains(Options.EXPORT_LABELS))
        exportLabels(body);
    /* Export Filters */
    if (options != null && options.contains(Options.EXPORT_FILTERS))
        exportFilters(body, dateFormat);
    /* Export Preferences */
    if (exportPreferences)
        exportPreferences(body);
    /* Write to File */
    FileOutputStream out = null;
    try {
        out = new FileOutputStream(destination);
        output.output(document, out);
        out.close();
    } catch (FileNotFoundException e) {
        throw new InterpreterException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
    } catch (IOException e) {
        throw new InterpreterException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
    } finally {
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                throw new InterpreterException(Activator.getDefault().createErrorStatus(e.getMessage(), e));
            }
        }
    }
}

34. JDOMUtil#writeDocument()

Project: intellij-community
File: JDOMUtil.java
public static void writeDocument(@NotNull Document document, @NotNull Writer writer, String lineSeparator) throws IOException {
    XMLOutputter xmlOutputter = createOutputter(lineSeparator);
    try {
        xmlOutputter.output(document, writer);
    } catch (NullPointerException ex) {
        getLogger().error(ex);
        printDiagnostics(document.getRootElement(), "");
    }
}

35. JDOMUtil#writeElement()

Project: intellij-community
File: JDOMUtil.java
public static void writeElement(@NotNull Element element, Writer writer, String lineSeparator) throws IOException {
    XMLOutputter xmlOutputter = createOutputter(lineSeparator);
    try {
        xmlOutputter.output(element, writer);
    } catch (NullPointerException ex) {
        getLogger().error(ex);
        printDiagnostics(element, "");
    }
}

36. XMLUtilities#createMobyDataElementWrapper()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
public static String createMobyDataElementWrapper(String xml, String queryID, Element serviceNotes) throws MobyException {
    if (xml == null)
        return null;
    Element element = createMobyDataElementWrapper(getDOMDocument(xml).getRootElement(), queryID, serviceNotes);
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    return (element == null ? null : outputter.outputString(element));
}

37. XMLUtilities#getCollection()

Project: incubator-taverna-plugin-bioinformatics
File: XMLUtilities.java
/**
	 *
	 * @param name
	 * @param xml
	 * @return
	 * @throws MobyException
	 */
public static String getCollection(String name, String xml) throws MobyException {
    Element element = getDOMDocument(xml).getRootElement();
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat().setOmitDeclaration(false));
    Element collection = getCollection(name, element);
    if (collection != null)
        return outputter.outputString(collection);
    return null;
}

38. MartServiceXMLHandlerTest#setUp()

Project: incubator-taverna-plugin-bioinformatics
File: MartServiceXMLHandlerTest.java
/*
	 * @see TestCase#setUp()
	 */
protected void setUp() throws Exception {
    super.setUp();
    xmlOutputter = new XMLOutputter();
    saxBuilder = new SAXBuilder();
    namespace = Namespace.getNamespace("test-namespace");
    martService = MartService.getMartService("url-location");
    martServiceXML = "<MartService xmlns=\"test-namespace\" location=\"url-location\" />";
    martUrlLocation = new MartURLLocation();
    martUrlLocation.setDefault(true);
    martUrlLocation.setDisplayName("location-display-name");
    martUrlLocation.setHost("host");
    martUrlLocation.setName("location-name");
    martUrlLocation.setPort(42);
    martUrlLocation.setServerVirtualSchema("server-virtual-schema");
    martUrlLocation.setVirtualSchema("virtual-schema");
    martUrlLocation.setVisible(false);
    martUrlLocation.setRedirect(true);
    martUrlLocationXML = "<MartURLLocation xmlns=\"test-namespace\" default=\"1\" displayName=\"location-display-name\" host=\"host\" name=\"location-name\" port=\"42\" serverVirtualSchema=\"server-virtual-schema\" virtualSchema=\"virtual-schema\" visible=\"0\" redirect=\"1\" />";
    martDataset = new MartDataset();
    martDataset.setDisplayName("dataset-display-name");
    martDataset.setInitialBatchSize(1);
    martDataset.setMartURLLocation(martUrlLocation);
    martDataset.setMaximumBatchSize(2);
    martDataset.setName("dataset-name");
    martDataset.setType("type");
    martDataset.setVisible(true);
    martDataset.setInterface("interface");
    martDataset.setModified("modified");
    martDatasetXML = "<MartDataset xmlns=\"test-namespace\" displayName=\"dataset-display-name\" name=\"dataset-name\" type=\"type\" initialBatchSize=\"1\" maximumBatchSize=\"2\" visible=\"true\" interface=\"interface\" modified=\"modified\"><MartURLLocation default=\"1\" displayName=\"location-display-name\" host=\"host\" name=\"location-name\" port=\"42\" serverVirtualSchema=\"server-virtual-schema\" virtualSchema=\"virtual-schema\" visible=\"0\" redirect=\"1\" /></MartDataset>";
    martRegistry = new MartRegistry();
    martRegistry.addMartURLLocation(martUrlLocation);
    martRegistryXML = "<MartRegistry xmlns=\"test-namespace\" ><virtualSchema xmlns=\"test-namespace\" name=\"virtual-schema\" visible=\"0\"><MartURLLocation xmlns=\"test-namespace\" default=\"1\" displayName=\"location-display-name\" host=\"host\" name=\"location-name\" port=\"42\" serverVirtualSchema=\"server-virtual-schema\" visible=\"0\" redirect=\"1\" /></virtualSchema></MartRegistry>";
    martRegistryXML2 = "<MartRegistry xmlns=\"test-namespace\" ><virtualSchema xmlns=\"test-namespace\" name=\"default\" visible=\"0\"><MartURLLocation xmlns=\"test-namespace\" default=\"1\" displayName=\"location-display-name\" host=\"host\" name=\"location-name\" port=\"42\" serverVirtualSchema=\"server-virtual-schema\" visible=\"0\" redirect=\"1\" /></virtualSchema></MartRegistry>";
}

39. XMLOutputSplitter#executeForComplexType()

Project: incubator-taverna-common-activities
File: XMLOutputSplitter.java
@SuppressWarnings({ "unchecked" })
private void executeForComplexType(Map<String, Object> result, List<String> outputNameList, List<Element> children, List<Attribute> list) throws IOException {
    XMLOutputter outputter = new XMLOutputter();
    for (Element child : children) {
        if (outputNameList.contains(child.getName())) {
            int i = outputNameList.indexOf(child.getName());
            TypeDescriptor descriptorForChild = ((ComplexTypeDescriptor) typeDescriptor).elementForName(outputNames[i]);
            if (outputTypes[i].startsWith("l(") && descriptorForChild instanceof ArrayTypeDescriptor && !((ArrayTypeDescriptor) descriptorForChild).isWrapped()) {
                boolean isXMLContent = outputTypes[i].contains("text/xml");
                result.put(child.getName(), extractDataListFromChildList(children, isXMLContent));
                break;
            } else {
                if (outputTypes[i].equals("'text/xml'") || outputTypes[i].equals("l('text/xml')")) {
                    String xmlText = outputter.outputString(child);
                    result.put(child.getName(), xmlText);
                } else if (outputTypes[i].equals("'application/octet-stream'")) {
                    byte[] data = DatatypeConverter.parseBase64Binary(child.getText());
                    result.put(child.getName(), data);
                } else if (outputTypes[i].equals("l('text/plain')")) {
                    // inner
                    // element
                    // containing
                    // a
                    // list
                    result.put(child.getName(), extractBaseTypeArrayFromChildren(child.getChildren()));
                } else {
                    result.put(child.getName(), child.getText());
                }
            }
        }
    }
    for (Attribute attribute : list) {
        if (outputNameList.contains("1" + attribute.getName())) {
            result.put("1" + attribute.getName(), attribute.getValue());
        } else if (outputNameList.contains(attribute.getName())) {
            result.put(attribute.getName(), attribute.getValue());
        }
    }
}

40. XMLInputSplitter#executeForComplexType()

Project: incubator-taverna-common-activities
File: XMLInputSplitter.java
private void executeForComplexType(Map<String, Object> inputMap, Map<String, String> result, Element outputElement) throws JDOMException, IOException {
    ComplexTypeDescriptor complexDescriptor = (ComplexTypeDescriptor) typeDescriptor;
    for (TypeDescriptor elementType : complexDescriptor.getElements()) {
        String key = elementType.getName();
        Object dataObject = inputMap.get(key);
        if (dataObject == null) {
            if (elementType.isOptional()) {
                continue;
            }
            if (elementType.isNillable()) {
                dataObject = "xsi:nil";
            } else {
                dataObject = "";
            }
        }
        if (dataObject instanceof List) {
            Element arrayElement = buildElementFromObject(key, "");
            String itemkey = "item";
            boolean wrapped = false;
            if (elementType instanceof ArrayTypeDescriptor) {
                wrapped = ((ArrayTypeDescriptor) elementType).isWrapped();
                TypeDescriptor arrayElementType = ((ArrayTypeDescriptor) elementType).getElementType();
                if (!wrapped) {
                    itemkey = elementType.getName();
                } else {
                    if (arrayElementType.getName() != null && arrayElementType.getName().length() > 0) {
                        itemkey = arrayElementType.getName();
                    } else {
                        itemkey = arrayElementType.getType();
                    }
                }
            }
            for (Object itemObject : ((List<?>) dataObject)) {
                Element dataElement = buildElementFromObject(itemkey, itemObject);
                dataElement.setNamespace(Namespace.getNamespace(elementType.getNamespaceURI()));
                if (!wrapped) {
                    dataElement.setName(itemkey);
                    outputElement.addContent(dataElement);
                } else {
                    arrayElement.addContent(dataElement);
                }
            }
            if (wrapped)
                outputElement.addContent(arrayElement);
        } else {
            Element dataElement = buildElementFromObject(key, dataObject);
            outputElement.addContent(dataElement);
        }
    }
    for (TypeDescriptor attribute : complexDescriptor.getAttributes()) {
        String key = attribute.getName();
        Object dataObject = inputMap.get("1" + key);
        if (dataObject == null) {
            dataObject = inputMap.get(key);
        }
        if (dataObject != null) {
            outputElement.setAttribute(key, dataObject.toString(), Namespace.getNamespace(attribute.getQname().getPrefix(), attribute.getNamespaceURI()));
        }
    }
    outputElement.setNamespace(Namespace.getNamespace(typeDescriptor.getNamespaceURI()));
    XMLOutputter outputter = new XMLOutputter();
    String xmlText = outputter.outputString(outputElement);
    result.put(outputNames[0], xmlText);
}

41. JdomTreeAdaptor#documentToString()

Project: freud
File: JdomTreeAdaptor.java
public static String documentToString(final Document document) {
    XMLOutputter outputter = new XMLOutputter();
    StringWriter writer = new StringWriter();
    try {
        outputter.output(document, writer);
        return writer.toString();
    } catch (IOException e) {
        return e.toString();
    }
}

42. JDOMUtil#writeDocument()

Project: consulo
File: JDOMUtil.java
public static void writeDocument(@NotNull Document document, @NotNull Writer writer, String lineSeparator) throws IOException {
    XMLOutputter xmlOutputter = createOutputter(lineSeparator);
    try {
        xmlOutputter.output(document, writer);
    } catch (NullPointerException ex) {
        getLogger().error(ex);
        printDiagnostics(document.getRootElement(), "");
    }
}

43. JDOMUtil#writeElement()

Project: consulo
File: JDOMUtil.java
public static void writeElement(@NotNull Element element, Writer writer, String lineSeparator) throws IOException {
    XMLOutputter xmlOutputter = createOutputter(lineSeparator);
    try {
        xmlOutputter.output(element, writer);
    } catch (NullPointerException ex) {
        getLogger().error(ex);
        printDiagnostics(element, "");
    }
}