org.jdom.output.XMLOutputter Java Examples

The following examples show how to use org.jdom.output.XMLOutputter. 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: StepConfigsDOM.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String createConfigXml(Map<String, StepsConfig> config) throws ApsSystemException {
	String xml = null;
	try {
		Element root = new Element(ROOT);
		Collection<StepsConfig> stepsConfigs = config.values();
		if (null != stepsConfigs) {
			Iterator<StepsConfig> iter = stepsConfigs.iterator();
			while (iter.hasNext()) {
				StepsConfig stepsConfig = iter.next();
				Element stepsConfigElements = this.createConfigElement(stepsConfig);
				root.addContent(stepsConfigElements);
			}
		}
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		Document doc = new Document(root);
		xml = out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating xml config", t);
		throw new ApsSystemException("Error creating xml config", t);
	}
	return xml;
}
 
Example #2
Source File: LazyGraphRegroupSaveableXML.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
/**
 * Overridden to create the {@link Element} to save at the time saving is taking place, 
 * instead of construction time.
 * 
 * @param objStorage The object into which the data will be placed.
 */
public void save(ObjectStorage objStorage) {
	Element groupVertexElement =
		GroupVertexSerializer.getXMLForRegroupableVertices(functionGraph);
	Document document = new Document(groupVertexElement);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	XMLOutputter xmlOutputter = new GenericXMLOutputter();

	try {
		xmlOutputter.output(document, outputStream);
	}
	catch (IOException ioe) {
		// shouldn't happen, as we are using our output stream
		Msg.error(getClass(), "Unable to save XML data.", ioe);
		return;
	}

	String xmlString = outputStream.toString();
	objStorage.putString(xmlString);
}
 
Example #3
Source File: LazyGraphGroupSaveableXML.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
/**
 * Overridden to create the {@link Element} to save at the time saving is taking place, 
 * instead of construction time.
 * 
 * @param objStorage The object into which the data will be placed.
 */
public void save(ObjectStorage objStorage) {
	Element groupVertexElement = GroupVertexSerializer.getXMLForGroupedVertices(functionGraph);
	Document document = new Document(groupVertexElement);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	XMLOutputter xmlOutputter = new GenericXMLOutputter();

	try {
		xmlOutputter.output(document, outputStream);
	}
	catch (IOException ioe) {
		// shouldn't happen, as we are using our output stream
		Msg.error(getClass(), "Unable to save XML data.", ioe);
		return;
	}

	String xmlString = outputStream.toString();
	objStorage.putString(xmlString);
}
 
Example #4
Source File: SaveableXML.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void save(ObjectStorage objStorage) {

	Document document = new Document(element);
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	XMLOutputter xmlOutputter = new GenericXMLOutputter();

	try {
		xmlOutputter.output(document, outputStream);
	}
	catch (IOException ioe) {
		// shouldn't happen, as we are using our output stream
		Msg.error(getClass(), "Unable to save XML data.", ioe);
		return;
	}

	String xmlString = outputStream.toString();
	objStorage.putString(xmlString);
}
 
Example #5
Source File: ToolUtils.java    From ghidra with Apache License 2.0 6 votes vote down vote up
public static boolean writeToolTemplate(ToolTemplate template) {

		USER_TOOLS_DIR.mkdirs();
		String toolName = template.getName();
		File toolFile = getToolFile(toolName);

		boolean status = false;
		try (OutputStream os = new FileOutputStream(toolFile)) {

			Element element = template.saveToXml();
			Document doc = new Document(element);
			XMLOutputter xmlout = new GenericXMLOutputter();
			xmlout.output(doc, os);
			os.close();

			status = true;

		}
		catch (Exception e) {
			Msg.error(LOGGER, "Error saving tool: " + toolName, e);
		}
		return status;
	}
 
Example #6
Source File: FrontEndTool.java    From ghidra with Apache License 2.0 6 votes vote down vote up
void saveToolConfigurationToDisk() {
	ToolTemplate template = saveToolToToolTemplate();
	Element root = new Element(FRONT_END_TOOL_XML_NAME);
	root.addContent(template.saveToXml());
	File saveFile = new File(Application.getUserSettingsDirectory(), FRONT_END_FILE_NAME);
	try {
		OutputStream os = new FileOutputStream(saveFile);
		org.jdom.Document doc = new org.jdom.Document(root);
		XMLOutputter xmlOut = new GenericXMLOutputter();
		xmlOut.output(doc, os);
		os.close();
	}
	catch (IOException e) {
		Msg.showError(this, null, "Error", "Error saving front end configuration", e);
	}
}
 
Example #7
Source File: OvalFileAggregator.java    From spacewalk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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\"", "");
}
 
Example #8
Source File: ToolServicesImpl.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public File exportTool(ToolTemplate tool) throws FileNotFoundException, IOException {

	File location = chooseToolFile(tool);
	if (location == null) {
		return location; // user cancelled
	}

	String filename = location.getName();
	if (!filename.endsWith(ToolUtils.TOOL_EXTENSION)) {
		filename = filename + ToolUtils.TOOL_EXTENSION;
	}

	try (FileOutputStream f =
		new FileOutputStream(location.getParent() + File.separator + filename)) {
		BufferedOutputStream bf = new BufferedOutputStream(f);
		Document doc = new Document(tool.saveToXml());
		XMLOutputter xmlout = new GenericXMLOutputter();
		xmlout.output(doc, bf);
	}

	return location;
}
 
Example #9
Source File: VTMatchSetTableDBAdapterV0.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private String getOptionsString(VTProgramCorrelator correlator) {
	ToolOptions options = correlator.getOptions();
	if (options.getOptionNames().isEmpty()) {
		return null;
	}
	Element optionsElement = options.getXmlRoot(true);

	XMLOutputter xmlout = new GenericXMLOutputter();
	StringWriter writer = new StringWriter();
	try {
		xmlout.output(optionsElement, writer);
		return writer.toString();
	}
	catch (IOException ioe) {
	}
	return null;
}
 
Example #10
Source File: VTSubToolManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void saveSubordinateToolConfig(PluginTool t) {
	String toolName = t.getName();
	String toolFileName = toolName + ".tool";
	File toolFile = new File(ToolUtils.getApplicationToolDirPath(), toolFileName);

	try {
		OutputStream os = new FileOutputStream(toolFile);
		Document doc = new Document(t.getToolTemplate(true).saveToXml());
		XMLOutputter xmlOut = new GenericXMLOutputter();
		xmlOut.output(doc, os);
		os.close();
	}
	catch (IOException e) {
		Msg.showError(this, t.getToolFrame(), "Version Tracking",
			"Failed to save source tool configuration\nFile: " + toolName + "\n" +
				e.getMessage());
	}
	t.setConfigChanged(false);
}
 
Example #11
Source File: JDOMUtils.java    From geowave with Apache License 2.0 6 votes vote down vote up
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) {
      LOGGER.error("Unable to retrieve the xml output", e);
      return null;
    }
  }
  return strOutput;
}
 
Example #12
Source File: OvalFileAggregator.java    From uyuni with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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\"", "");
}
 
Example #13
Source File: StepConfigsDOM.java    From entando-components with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String createConfigXml(StepsConfig stepsConfig) throws ApsSystemException {
	String xml = null;
	try {
		Element root =  this.createConfigElement(stepsConfig);
		XMLOutputter out = new XMLOutputter();
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
		Document doc = new Document(root);
		xml = out.outputString(doc);
	} catch (Throwable t) {
		_logger.error("Error creating xml config", t);
		throw new ApsSystemException("Error creating xml config", t);
	}
	return xml;
}
 
Example #14
Source File: RunConfigurationSerializerTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void testRunConfigurationUnalteredBySerializationRoundTrip() throws InvalidDataException {
  configuration.setTarget(Label.create("//package:rule"));
  configuration.setKeepInSync(true);

  Element initialElement = runManager.getState();

  Element element = RunConfigurationSerializer.writeToXml(configuration);
  assertThat(RunConfigurationSerializer.findExisting(getProject(), element)).isNotNull();

  clearRunManager(); // remove configuration from project
  RunConfigurationSerializer.loadFromXmlElementIgnoreExisting(getProject(), element);

  Element newElement = runManager.getState();
  XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  assertThat(xmlOutputter.outputString(newElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example #15
Source File: UserShortcutConfigDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected static String createUserConfigXml(String[] config) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element rootElement = new Element(ROOT_ELEMENT_NAME);
		document.setRootElement(rootElement);
		for (int i = 0; i < config.length; i++) {
			String shortcut = config[i];
			if (null != shortcut) {
				Element element = new Element(BOX_ELEMENT_NAME);
				element.setAttribute(POS_ATTRIBUTE_NAME, String.valueOf(i));
				element.setText(shortcut);
				rootElement.addContent(element);
			}
		}
	} catch (Throwable t) {
		_logger.error("Error parsing user config", t);
		//ApsSystemUtils.logThrowable(t, UserShortcutConfigDOM.class, "extractUserShortcutConfig");
		throw new ApsSystemException("Error parsing user config", t);
	}
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	out.setFormat(format);
	return out.outputString(document);
}
 
Example #16
Source File: EntityTypeDOM.java    From entando-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public String getXml(IApsEntity entityType) throws ApsSystemException {
	XMLOutputter out = new XMLOutputter();
	Document document = new Document();
	try {
		Element entityTypeElement = this.createTypeElement(entityType);
		document.setRootElement(entityTypeElement);
		Format format = Format.getPrettyFormat();
		format.setIndent("\t");
		out.setFormat(format);
	} catch (Throwable t) {
		_logger.error("Error building xml", t);
		throw new ApsSystemException("Error building xml", t);
	}
	return out.outputString(document);
}
 
Example #17
Source File: XMLModelIdentifiable.java    From beast-mcmc with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void print(XMLOutputter outputter, OutputStream ostream) {
    if (ostream == null) {
        ostream = System.out;
    }
    try {
        if (defined) {
            outputter.output(definition, ostream);
        } else {
            outputter.output(definitionIdref, ostream);
        }
        for (Element ref : references) {
            outputter.output(ref, ostream);
        }

    } catch (IOException e) {
        System.err.println(e);
    }
}
 
Example #18
Source File: BlazeCommandRunConfigurationRunManagerImplTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void loadStateAndGetStateElementShouldMatchAfterChangeAndRevert() {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());
  final Label label = Label.create("//package:rule");
  configuration.setTarget(label);

  final Element initialElement = runManager.getState();
  runManager.loadState(initialElement);
  final BlazeCommandRunConfiguration modifiedConfiguration =
      (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
  modifiedConfiguration.setTarget(Label.create("//new:label"));

  final Element modifiedElement = runManager.getState();
  assertThat(xmlOutputter.outputString(modifiedElement))
      .isNotEqualTo(xmlOutputter.outputString(initialElement));
  runManager.loadState(modifiedElement);
  final BlazeCommandRunConfiguration revertedConfiguration =
      (BlazeCommandRunConfiguration) runManager.getAllConfigurations()[0];
  revertedConfiguration.setTarget(label);

  final Element revertedElement = runManager.getState();
  assertThat(xmlOutputter.outputString(revertedElement))
      .isEqualTo(xmlOutputter.outputString(initialElement));
}
 
Example #19
Source File: BlazeCommandRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws Exception {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  state.getCommandState().setCommand(COMMAND);
  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exeFlag1"));
  state.getBlazeBinaryState().setBlazeBinary("/usr/bin/blaze");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #20
Source File: BlazeAndroidRunConfigurationCommonStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  state.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  state.getExeFlagsState().setRawFlags(ImmutableList.of("--exe1", "--exe2"));
  state.setNativeDebuggingEnabled(true);

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #21
Source File: BlazeAndroidTestRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  commonState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  commonState.setNativeDebuggingEnabled(true);

  state.setTestingType(BlazeAndroidTestRunConfigurationState.TEST_METHOD);
  state.setInstrumentationRunnerClass("com.example.TestRunner");
  state.setMethodName("fooMethod");
  state.setClassName("BarClass");
  state.setPackageName("com.test.package.name");
  state.setLaunchMethod(AndroidTestLaunchMethod.MOBILE_INSTALL);
  state.setExtraOptions("--option");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #22
Source File: BlazeAndroidBinaryRunConfigurationStateTest.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Test
public void repeatedWriteShouldNotChangeElement() throws WriteExternalException {
  final XMLOutputter xmlOutputter = new XMLOutputter(Format.getCompactFormat());

  BlazeAndroidRunConfigurationCommonState commonState = state.getCommonState();
  commonState.getBlazeFlagsState().setRawFlags(ImmutableList.of("--flag1", "--flag2"));
  commonState.setNativeDebuggingEnabled(true);

  state.setActivityClass("com.example.TestActivity");
  state.setMode(BlazeAndroidBinaryRunConfigurationState.LAUNCH_SPECIFIC_ACTIVITY);
  state.setLaunchMethod(AndroidBinaryLaunchMethod.MOBILE_INSTALL);
  state.setUseSplitApksIfPossible(false);
  state.setUseWorkProfileIfPresent(true);
  state.setUserId(2);
  state.setShowLogcatAutomatically(true);
  state.setDeepLink("http://deeplink");

  Element firstWrite = new Element("test");
  state.writeExternal(firstWrite);
  Element secondWrite = firstWrite.clone();
  state.writeExternal(secondWrite);

  assertThat(xmlOutputter.outputString(secondWrite))
      .isEqualTo(xmlOutputter.outputString(firstWrite));
}
 
Example #23
Source File: CreoleRegisterImpl.java    From gate-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void processFullCreoleXmlTree(Plugin plugin,
    Document jdomDoc, CreoleAnnotationHandler annotationHandler)
    throws GateException, IOException, JDOMException {
  // now we can process any annotations on the new classes
  // and augment the XML definition
  annotationHandler.processAnnotations(jdomDoc);

  // debugging
  if(DEBUG) {
    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
    xmlOut.output(jdomDoc, System.out);
  }

  // finally, parse the augmented definition with the normal parser
  DefaultHandler handler =
      new CreoleXmlHandler(this, plugin);
  SAXOutputter outputter =
      new SAXOutputter(handler, handler, handler, handler);
  outputter.output(jdomDoc);
  if(DEBUG) {
    Out.prln("done parsing " + plugin);
  }
}
 
Example #24
Source File: AbstractSamlObjectBuilder.java    From springboot-shiro-cas-mybatis with MIT License 6 votes vote down vote up
/**
 * Convert the received jdom doc to a Document element.
 *
 * @param doc the doc
 * @return the org.w3c.dom. document
 */
private org.w3c.dom.Document toDom(final Document doc) {
    try {
        final XMLOutputter xmlOutputter = new XMLOutputter();
        final StringWriter elemStrWriter = new StringWriter();
        xmlOutputter.output(doc, elemStrWriter);
        final byte[] xmlBytes = elemStrWriter.toString().getBytes(Charset.defaultCharset());
        final DocumentBuilderFactory dbf = DocumentBuilderFactory
                .newInstance();
        dbf.setNamespaceAware(true);
        return dbf.newDocumentBuilder().parse(
                new ByteArrayInputStream(xmlBytes));
    } catch (final Exception e) {
        logger.trace(e.getMessage(), e);
        return null;
    }
}
 
Example #25
Source File: ApsEntityDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Return the XML structure of the entity.
 * @return String The XML structure of the entity.
 */
@Override
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	String xml = out.outputString(_doc);
	return xml;
}
 
Example #26
Source File: ApsPropertiesDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Restituisce il formato xml delle Properties.
 * @return String Formato xml delle Properties.
 */
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	format.setIndent("");
	out.setFormat(format);
	return out.outputString(_doc);
}
 
Example #27
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 #28
Source File: LangDOM.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Restutuisce l'xml del documento.
 * @return L'xml del documento.
 */
public String getXMLDocument(){
	XMLOutputter out = new XMLOutputter();
	Format format = Format.getPrettyFormat();
	out.setFormat(format);
	String xml = out.outputString(this.doc);
	return xml;
}
 
Example #29
Source File: AbstractParser.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public Element
 getXML(CartridgeLoader the_cartridge,
        String the_file) throws IOException, ParseException {
   Element result=null;
   try {
result=builder.build(the_cartridge.getFile(the_file)).getRootElement();
     XMLOutputter outputter = new XMLOutputter();
   } catch (Exception e) {
     throw new ParseException(e);
   }
   return result;
 }
 
Example #30
Source File: JDOMUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static String writeElementToStringWithoutHeader(final Element e) {
  try {
    final StringWriter sw = new StringWriter();
    final XMLOutputter outputter = new XMLOutputter();

    outputter.output(e, sw);

    return sw.getBuffer().toString();
  } catch (final IOException ioe) {
    LOGGER.info("write error", ioe);
  }

  return null;
}