Example usage for org.dom4j.util NodeComparator NodeComparator

List of usage examples for org.dom4j.util NodeComparator NodeComparator

Introduction

In this page you can find the example usage for org.dom4j.util NodeComparator NodeComparator.

Prototype

NodeComparator

Source Link

Usage

From source file:com.globalsight.terminology.EntryUtils.java

License:Apache License

/**
 * <p>Merges the information in entry2 into entry1.</p>
 *
 * @return the modified version of entry1.
 *///ww  w  . j a  v a  2 s .co  m
public static Entry mergeTbxEntries(Entry p_one, Entry p_two) throws TermbaseException {
    Entry result = new Entry();

    pruneEntry(p_one);
    pruneEntry(p_two);

    Document dom1 = p_one.getDom();
    Element root1 = dom1.getRootElement();

    Document dom2 = p_two.getDom();
    Element root2 = dom2.getRootElement();

    NodeComparator comp = new NodeComparator();
    mergeTbxInnerGroups(root1, root2, comp);

    // let entry 1 know its dom is dirty
    result.setDom(root1.getDocument());

    return result;
}

From source file:com.globalsight.terminology.EntryUtils.java

License:Apache License

/**
 * <p>Merges the information in entry2 into entry1.</p>
 *
 * @return the modified version of entry1.
 *//*ww  w  .  j  a v  a  2s .  c  o m*/
static public Entry mergeEntries(Entry p_one, Entry p_two) throws TermbaseException {
    // Remove empty fields and normalize whitespace.
    pruneEntry(p_one);
    pruneEntry(p_two);

    Document dom1 = p_one.getDom();
    Element root1 = dom1.getRootElement();

    Document dom2 = p_two.getDom();
    Element root2 = dom2.getRootElement();

    NodeComparator comp = new NodeComparator();
    mergeInnerGroups(root1, root2, comp);

    // let entry 1 know its dom is dirty
    p_one.setDom(dom1);

    return p_one;
}

From source file:org.orbeon.oxf.xml.dom4j.NonLazyUserDataElement.java

License:Open Source License

/**
 * @return A clone.  The clone will have parent == null but will have any necessary namespace
 *         declarations this element's ancestors.
 *//*ww  w  .  j av  a 2  s. c  o m*/
public Object clone() {
    final NonLazyUserDataElement ret = cloneInternal();
    org.dom4j.Element anstr = getParent();
    done: if (anstr != null) {
        final NodeComparator nc = new NodeComparator();
        final java.util.TreeSet nsSet = new java.util.TreeSet(nc);

        do {
            final java.util.List sibs = anstr.content();
            for (final java.util.Iterator itr = sibs.iterator(); itr.hasNext();) {
                final org.dom4j.Node sib = (org.dom4j.Node) itr.next();
                if (sib.getNodeType() != org.dom4j.Node.NAMESPACE_NODE)
                    continue;
                nsSet.add(sib);
            }
            anstr = anstr.getParent();
        } while (anstr != null);
        if (nsSet.isEmpty())
            break done;
        for (final java.util.Iterator itr = nsSet.iterator(); itr.hasNext();) {
            final org.dom4j.Namespace ns = (org.dom4j.Namespace) itr.next();
            final String pfx = ns.getPrefix();
            if (ret.getNamespaceForPrefix(pfx) != null)
                continue;
            ret.add(ns);
        }
    }
    return ret;
}