Java Code Examples for org.jdom.output.Format#getRawFormat()

The following examples show how to use org.jdom.output.Format#getRawFormat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GappModel.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Write out the (possibly modified) GAPP file to its new location.
 * 
 * @throws IOException if an I/O error occurs.
 */
public void write() throws IOException {
  finish();
  File newGappFile = Files.fileFromURL(gappFileURL);
  FileOutputStream fos = new FileOutputStream(newGappFile);
  BufferedOutputStream out = new BufferedOutputStream(fos);

  XMLOutputter outputter = new XMLOutputter(Format.getRawFormat());
  outputter.output(gappDocument, out);
}
 
Example 2
Source File: XmlExporterServiceImpl.java    From rice with Educational Community License v2.0 5 votes vote down vote up
public byte[] export(ExportDataSet dataSet) {
    if (dataSet == null) {
        throw new IllegalArgumentException("Xml Exporter cannot handle NULL data.");
    }
    Element rootElement = new Element(DATA_ELEMENT, WORKFLOW_NAMESPACE);
    rootElement.addNamespaceDeclaration(SCHEMA_NAMESPACE);
    rootElement.setAttribute(SCHEMA_LOCATION_ATTR, WORKFLOW_SCHEMA_LOCATION, SCHEMA_NAMESPACE);
    Document document = new Document(rootElement);
    boolean shouldPrettyPrint = true;
    for (XmlExporter exporter : xmlImpexRegistry.getExporters()) {
    	Element exportedElement = exporter.export(dataSet);
    	if (exportedElement != null) {
    		if (!exporter.supportPrettyPrint()) {
    			shouldPrettyPrint = false;
    		}
    		appendIfNotEmpty(rootElement, exportedElement);
    	}
    }

    // TODO: KULRICE-4420 - this needs cleanup
    Format f;
    if (!shouldPrettyPrint) {
        f = Format.getRawFormat();
        f.setExpandEmptyElements(false);
        f.setTextMode(Format.TextMode.PRESERVE);
    } else {
        f = Format.getPrettyFormat();
    }
    XMLOutputter outputer = new XMLOutputter(f);
    StringWriter writer = new StringWriter();
    try {
        outputer.output(document, writer);
    } catch (IOException e) {
        throw new WorkflowRuntimeException("Could not write XML data export.", e);
    }
    return writer.toString().getBytes();
}
 
Example 3
Source File: Samdas.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Get the contents of this Samdas in form of an XML-String
 */
@Override
public String toString(){
	XMLOutputter xo = new XMLOutputter(Format.getRawFormat());
	return xo.outputString(doc);
}
 
Example 4
Source File: EnhancedTextField.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Alle Änderungen seit dem letzten speichern zurücknehmen
 * 
 * @TODO: multi-undo
 */
public void undo(){
	XMLOutputter xo = new XMLOutputter(Format.getRawFormat());
	String oldText = xo.outputString(samdas.getDocument());
	setText(oldText);
}
 
Example 5
Source File: EnhancedTextField.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Liefert den Inhalt des Textfelds als XML-Text zurück
 */
@Override
public String getContentsAsXML(){
	XMLOutputter xo = new XMLOutputter(Format.getRawFormat());
	return xo.outputString(getDocument());
}
 
Example 6
Source File: XmlJotter.java    From rice with Educational Community License v2.0 2 votes vote down vote up
/**
 * Internal function to choose a format based on a boolean flag.
 *
 * @param indent whether to use indented or raw format
 * @return The format
 */
private static Format getJdomFormat(boolean indent) {
    return indent ? Format.getPrettyFormat() : Format.getRawFormat();
}