Example usage for org.dom4j Attribute setData

List of usage examples for org.dom4j Attribute setData

Introduction

In this page you can find the example usage for org.dom4j Attribute setData.

Prototype

void setData(Object data);

Source Link

Document

Sets the data value of this attribute if this element supports data binding or calls Node#setText(String) if it doesn't.

Usage

From source file:org.orbeon.oxf.xforms.InstanceData.java

License:Open Source License

private static InstanceData createNewInstanceData(Node node) {
    final InstanceData instanceData;
    if (node instanceof Element) {
        final Element element = (Element) node;
        instanceData = InstanceData.createNewInstanceData(element.getData());
        element.setData(instanceData);//ww  w .  j av a 2 s  .  c o m
    } else if (node instanceof Attribute) {
        final Attribute attribute = (Attribute) node;
        instanceData = InstanceData.createNewInstanceData(attribute.getData());
        attribute.setData(instanceData);
    } else if (node instanceof Document) {
        // We can't store data on the Document object. Use root element instead.
        final Element element = ((Document) node).getRootElement();
        instanceData = InstanceData.createNewInstanceData(element.getData());
        element.setData(instanceData);
    } else {
        // No other node type is supported
        throw new OXFException("Cannot create InstanceData on node type: " + node.getNodeTypeName());
    }
    return instanceData;
}