Java Utililty Methods XML Attribute Merge

List of utility methods to do XML Attribute Merge

Description

The list of methods to do XML Attribute Merge are organized into topic(s).

Method

StartElementmergeAttributes(StartElement tag, Iterator attrs, XMLEventFactory factory)
Constructs a new StartElement that merges the attributes and namespaces found in the specified StartElement, with the provided attributes.
Map attributes = new HashMap();
for (Iterator i = tag.getAttributes(); i.hasNext();) {
    Attribute attr = (Attribute) i.next();
    attributes.put(attr.getName(), attr);
while (attrs.hasNext()) {
    Attribute attr = (Attribute) attrs.next();
    attributes.put(attr.getName(), attr);
...
StartElementmergeAttributes(StartElement tag, Iterator attrs, Iterator nsps, XMLEventFactory factory)
Like javanet.staxutils.XMLStreamUtils#mergeAttributes but it can also merge namespaces
Map<QName, Attribute> attributes = new HashMap<QName, Attribute>();
for (Iterator i = tag.getAttributes(); i.hasNext();) {
    Attribute attr = (Attribute) i.next();
    attributes.put(attr.getName(), attr);
if (attrs != null) {
    while (attrs.hasNext()) {
        Attribute attr = attrs.next();
...
ArrayListmergeByAttrib(ArrayList master, ArrayList slave, String attrib)
merge By Attrib
Map<String, Element> masterMap = mapFromArrayListByAttribute(master, attrib);
Map<String, Element> slaveMap = mapFromArrayListByAttribute(slave, attrib);
slaveMap.putAll(masterMap);
ArrayList<Element> res = new ArrayList<Element>();
Collection<Element> collection = slaveMap.values();
for (Element e : collection) {
    res.add(e);
return res;