Example usage for org.dom4j.tree FlyweightAttribute FlyweightAttribute

List of usage examples for org.dom4j.tree FlyweightAttribute FlyweightAttribute

Introduction

In this page you can find the example usage for org.dom4j.tree FlyweightAttribute FlyweightAttribute.

Prototype

public FlyweightAttribute(QName qname) 

Source Link

Usage

From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JAdapter.java

License:Open Source License

/**
 * Sets the ino:docname on this DOM4J specific TXMLObject.
 *
 * @param docname is the ino:docname attribute of the data object.
 *//*from ww w.j  ava 2s  .  c  o  m*/
public void setDocname(String docname) {
    if (docname == null || docname.equals("")) {
        if (element == null)
            super.setDocname(null);
        else {
            QName qname = new QName(TInoNamespace.DOCNAME.getName(), inoNamespace);
            Attribute att = new FlyweightAttribute(qname);
            element.remove(att);
        }
    } else {
        if (element == null)
            super.setDocname(docname);
        else {
            QName qname = new QName(TInoNamespace.DOCNAME.getName(), inoNamespace);
            Attribute att = element.attribute(qname);
            if (att != null)
                att.setValue(docname);
            else {
                att = new FlyweightAttribute(TInoNamespace.DOCNAME.getName(), docname, inoNamespace);
                element.add(att);
            }
        }
    }
}

From source file:org.orbeon.oxf.processor.tamino.dom4j.TDOM4JAdapter.java

License:Open Source License

/**
 * Sets the ino:id for the XML instance.
 *///from  w  w  w . j ava2  s.  c  om
public void setId(String inoId) {
    if (inoId == null || inoId.length() == 0) {
        if (element == null)
            super.setId(null);
        else {
            QName qtmpName = new QName(TInoNamespace.ID.getName(), inoNamespace);
            Attribute tmpAttribute = new FlyweightAttribute(qtmpName);
            element.remove(tmpAttribute);
        }
    } else {
        if (element == null)
            super.setId(inoId);
        else {
            QName qname = new QName(TInoNamespace.ID.getName(), inoNamespace);
            Attribute att = element.attribute(qname);
            if (att != null)
                att.setValue(inoId);
            else {
                att = new FlyweightAttribute(TInoNamespace.ID.getName(), inoId, inoNamespace);
                element.add(att);
            }
        }
    }
}