Example usage for org.dom4j.io SAXWriter writeClose

List of usage examples for org.dom4j.io SAXWriter writeClose

Introduction

In this page you can find the example usage for org.dom4j.io SAXWriter writeClose.

Prototype

public void writeClose(Element element) throws SAXException 

Source Link

Document

Writes the closing tag of an Element

Usage

From source file:org.apache.commons.jelly.tags.xml.CopyTag.java

License:Apache License

public void doTag(XMLOutput output) throws JellyTagException {
    Object xpathContext = getXPathContext();

    Object node = xpathContext;/*from  w w w .  j  av  a 2s.c o  m*/

    try {
        if (select != null) {
            node = select.selectSingleNode(xpathContext);
        }

        if (node instanceof Element) {
            Element element = (Element) node;

            SAXWriter saxWriter;

            if (lexical) {
                saxWriter = new SAXWriter(output, output);
            } else {
                saxWriter = new SAXWriter(output);
            }

            saxWriter.writeOpen(element);
            invokeBody(output);
            saxWriter.writeClose(element);
        } else {
            invokeBody(output);
        }
    } catch (SAXException e) {
        throw new JellyTagException(e);
    } catch (JaxenException e) {
        throw new JellyTagException(e);
    }
}