Example usage for javax.xml.transform.dom DOMResult getNextSibling

List of usage examples for javax.xml.transform.dom DOMResult getNextSibling

Introduction

In this page you can find the example usage for javax.xml.transform.dom DOMResult getNextSibling.

Prototype

public Node getNextSibling() 

Source Link

Document

Get the child node before which the result nodes will be inserted.

Usage

From source file:net.sf.joost.emitter.DOMEmitter.java

/**
 * DefaultConstructor//from  ww w .  ja  va 2 s  . com
 *
 * @throws ParserConfigurationException
 *                 if an error occurs while creating
 *                 {@link javax.xml.parsers.DocumentBuilder}
 *                 DOM-DocumentBuilder
 */
public DOMEmitter(DOMResult result) throws ParserConfigurationException {
    if (DEBUG)
        log.debug("init DOMEmitter");

    Node rootNode = result.getNode();
    nextSiblingOfRootNodes = result.getNextSibling();
    if (rootNode != null) {
        // use the document of the provided node
        if (rootNode instanceof Document)
            document = (Document) rootNode;
        else
            document = rootNode.getOwnerDocument();

        stack.push(rootNode);
    } else {
        // create a new document
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = factory.newDocumentBuilder();
        document = docBuilder.newDocument();

        stack.push(document);
    }
}