Java Utililty Methods XML QName Get

List of utility methods to do XML QName Get

Description

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

Method

QNamegetQName(String namespaceURI, String localPart)
get Q Name
QName name = new QName(namespaceURI, localPart);
return name;
QNamegetQName(String qname)
get Q Name
String ns = qname.substring(1, qname.indexOf("}"));
String localName = qname.substring(qname.indexOf("}") + 2);
return new QName(ns, localName);
QNamegetQName(String text, String defaultNamespace, NamespaceContext context)
Construct a QName from an XML value.
if (text == null || text.length() == 0) {
    return null;
int index = text.indexOf(':');
if (index < 1 || index == text.length() - 1) {
    return new QName(defaultNamespace, text);
} else {
    String prefix = text.substring(0, index);
...
QNamegetQName(String value, Node node)
get Q Name
if (value == null) {
    return null;
int index = value.indexOf(":");
if (index == -1) {
    return new QName(value);
String prefix = value.substring(0, index);
...
StringgetQNameAttribute(Map attributes, QName qName)
get Q Name Attribute
return attributes.get(qName);
QNamegetQNameAttribute(Node n, String namespace, String attributeName)
get Q Name Attribute
Node attrib = n.getAttributes().getNamedItem(attributeName);
if (attrib == null)
    return null;
String value = attrib.getNodeValue();
assert (value != null);
if (namespace == null)
    return new QName(value);
else
...
ComparatorgetQNameComparator()
Get a new Comparator comparing QName s.
final Comparator<QName> comparator = (o1, o2) -> {
    if (o1 == o2) {
        return 0;
    } else if (o2 == null) {
        return -1;
    } else if (o1 == null) {
        return 1;
    } else {
...
StringgetQNameConstant(QName name)
get Q Name Constant
return (String) typeMap.get(name);
QNamegetQNameForNode(Node node)
Returns the qualified name of the given DOM Node.
if (node.getNamespaceURI() != null && node.getPrefix() != null && node.getLocalName() != null) {
    return createQName(node.getNamespaceURI(), node.getLocalName(), node.getPrefix());
} else if (node.getNamespaceURI() != null && node.getLocalName() != null) {
    return new QName(node.getNamespaceURI(), node.getLocalName());
} else if (node.getLocalName() != null) {
    return new QName(node.getLocalName());
} else {
    return new QName(node.getNodeName());
...
QNamegetQNameFromSerialzedForm(String qNameAsString)
get Q Name From Serialzed Form
int pos = qNameAsString.lastIndexOf("}"); 
String ns = qNameAsString.substring(1, pos);
String name = qNameAsString.substring(pos + 1, qNameAsString.length());
QName qName = new QName(ns, name);
return qName;