Example usage for org.dom4j.io STAXEventWriter writeNode

List of usage examples for org.dom4j.io STAXEventWriter writeNode

Introduction

In this page you can find the example usage for org.dom4j.io STAXEventWriter writeNode.

Prototype

public void writeNode(Node n) throws XMLStreamException 

Source Link

Document

Writes a DOM4J Node to the stream.

Usage

From source file:org.compass.core.xml.dom4j.converter.STAXReaderXmlContentConverter.java

License:Apache License

public String toXml1(XmlObject xmlObject) throws ConversionException {
    //TODO for some reason, this does not marshall at all, and also, will it be faster than dom4j XMLWriter?
    Dom4jXmlObject dom4jXmlObject = (Dom4jXmlObject) xmlObject;
    StringBuilderWriter stringWriter = StringBuilderWriter.Cached.cached();
    try {/* w ww  .  j a  va  2 s. co  m*/
        STAXEventWriter xmlWriter = new STAXEventWriter(stringWriter);
        xmlWriter.writeNode(dom4jXmlObject.getNode());
    } catch (XMLStreamException e) {
        throw new ConversionException("Failed to write xml", e);
    }
    return stringWriter.toString();
}