Java Utililty Methods XML QName Parse

List of utility methods to do XML QName Parse

Description

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

Method

QNameparseQName(String qname, Element namespaceContext)
Parses the given String into a QName object and resolves the prefix to a namespace URI.
int colonIndex = qname.indexOf(':');
String prefix = null;
if (colonIndex >= 0)
    prefix = qname.substring(0, colonIndex);
String localName = qname.substring(colonIndex + 1);
String uri = null;
if (namespaceContext != null)
    uri = resolveNamespace(qname, namespaceContext);
...
QNameparseQName(URI u)
Converts a URI into a QName, based entirely on parsing.
String s = u.toString();
for (int i = s.length() - 1; i > 0; i--) {
    if (!localNameChar(s.charAt(i))) {
        for (int p = i + 1; p < s.length(); p++) {
            if (localStartNameChar(s.charAt(p)))
                return new QName(s.substring(0, p), s.substring(p));
        return new QName(s);
...
QNameparseQNameString(String qNameString)
Parse the given qualified name string into a QName.
Assert.hasLength(qNameString, "QName text may not be null or empty");
if (qNameString.charAt(0) != '{') {
    return new QName(qNameString);
} else {
    int endOfNamespaceURI = qNameString.indexOf('}');
    if (endOfNamespaceURI == -1) {
        throw new IllegalArgumentException(
                "Cannot create QName from \"" + qNameString + "\", missing closing \"}\"");
...
QNameparseQNameString(String qns)
parse Q Name String
if (qns != null) {
    Matcher m = QNAME_PAT.matcher(qns);
    if (m.matches() && m.group(4) != null) {
        return new QName(m.group(3), m.group(5), m.group(4));
    } else {
        return new QName(qns);
} else {
...