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

QNamegetElementQName(Class type)
get Element Q Name
if (elementCache.containsKey(type))
    return elementCache.get(type);
try {
    Field typeField;
    try {
        typeField = type.getDeclaredField("DEFAULT_ELEMENT_NAME");
    } catch (NoSuchFieldException ex) {
        typeField = type.getDeclaredField("ELEMENT_NAME");
...
QNamegetElementQName(Element element)
Returns the QName of the element.
if (element.getPrefix() != null) {
    return new QName(element.getNamespaceURI(), element.getLocalName(), element.getPrefix());
} else {
    return new QName(element.getNamespaceURI(), element.getLocalName());
QNamegetElementQName(Element xml)
get Element Q Name
String uri = xml.getNamespaceURI();
String prefix = xml.getPrefix();
String name = xml.getLocalName();
if (name == null)
    return new QName(xml.getNodeName());
if (prefix != null && prefix.length() > 0)
    return new QName(uri, name, prefix);
return new QName(uri, name);
...
QNamegetElementQName(final Element el)
get Element Q Name
final String qualifiedName = el.getNodeName();
return resolveQName(el, qualifiedName);
Element[]getElements(Node context, QName qname)
get Elements
String name = qname.getLocalPart();
String namespace = qname.getNamespaceURI();
return getAllElements(context, namespace, name);
StringgetName(QName qName)
get Name
return qName.getLocalPart() + " - " + qName.getNamespaceURI();
StringgetName(QName qname)
get Name
String prefix = qname.getPrefix();
String name = qname.getLocalPart();
return (prefix != null && !"".equals(prefix)) ? prefix + ":" + name : name;
QNamegetQName(@Nonnull final Element aElement)
Get the QName of the passed element.
final String sNamespaceURI = aElement.getNamespaceURI();
if (sNamespaceURI == null)
    return new QName(aElement.getTagName());
return new QName(sNamespaceURI, aElement.getLocalName(), getPrefix(aElement));
QNamegetQName(Class klass)
get Q Name
XmlType xmlType = klass.getAnnotation(XmlType.class);
if (xmlType == null)
    return null;
String namespace = getNamespace(klass);
String name = xmlType.name();
return new QName(namespace, name);
QNamegetQName(Element el)
Build a QName from the element name
if (el == null) {
    return null;
} else if (el.getNamespaceURI() == null) {
    return new QName(el.getNodeName());
} else if (el.getPrefix() != null) {
    return new QName(el.getNamespaceURI(), el.getLocalName(), el.getPrefix());
} else {
    return new QName(el.getNamespaceURI(), el.getLocalName());
...