Java Utililty Methods XML QName

List of utility methods to do XML QName

Description

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

Method

voidaddInfo(final QName nm, final Integer kind, final Class cl)
add Info
compNames.put(cl, nm);
compKinds.put(nm, kind);
voidaddNamespace(Element element, QName qName)
add Namespace
element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + qName.getLocalPart(),
        qName.getNamespaceURI());
voidaddTypeQname(QName elemntNameSpace, List propertyQnameValueList, PropertyDescriptor propDesc, QName beanName, boolean processingDocLitBare)
add Type Qname
if (elemntNameSpace != null) {
    propertyQnameValueList.add(
            new QName(elemntNameSpace.getNamespaceURI(), propDesc.getName(), elemntNameSpace.getPrefix()));
} else {
    if (processingDocLitBare) {
        propertyQnameValueList.add(new QName(propDesc.getName()));
    } else {
        propertyQnameValueList
...
booleancompareQName(QName qname, Node node)
compare Q Name
return (qname.getNamespaceURI().equals(node.getNamespaceURI())
        && qname.getLocalPart().equals(node.getLocalName()));
booleancompareRelation(QName a, QName b)
compare Relation
if (a == null && b == null) {
    return true;
if (a == null || b == null) {
    return false;
return a.equals(b);
booleancompareWithOutNamespace(QName value, QName tagName)
Compare two XML tags
if (value != null) {
    return (value.getLocalPart().equals(tagName.getLocalPart()));
return false;
StringconcatAttributes(List startElements, QName attrName)
Concatenates the value of the attribute named attrName for all elements in startElements.
String announcements = "";
for (int i = 0; i < startElements.size(); i++) {
    StartElement se = startElements.get(i);
    for (Iterator<?> atIt = se.getAttributes(); atIt.hasNext();) {
        Attribute at = (Attribute) atIt.next();
        if (attrName.equals(at.getName())) {
            announcements += at.getValue() + " ";
            break;
...
booleancontains(final QName[] qnames, final QName qname, final String defaultNamespace)
contains
for (QName a : qnames) {
    if (equal(a, qname, defaultNamespace)) {
        return true;
return false;
SortedMap>convertQNameListToNamespaceToLocalNameList( List list)
convert Q Name List To Namespace To Local Name List
SortedMap<String, SortedSet<String>> res = new TreeMap<>();
for (QName qname : list) {
    SortedSet<String> localNameSet = res.computeIfAbsent(qname.getNamespaceURI(), k -> new TreeSet<>());
    localNameSet.add(qname.getLocalPart());
return res;
StringconvertQNameToFullname(QName qn)
convert Q Name To Fullname
String returnValue = "";
String nsu = qn.getNamespaceURI();
if (nsu != null && nsu.length() != 0) {
    returnValue = "{" + nsu + "}";
returnValue += qn.getLocalPart();
return returnValue;