Returns a QName holding the value of the specified String.
The string must be in the form returned by the QName.toString()
method, i.e. "{namespaceURI}localPart", with the "{namespaceURI}"
part being optional.
This method doesn't do a full validation of the resulting QName.
In particular, it doesn't check that the resulting namespace URI
is a legal URI (per RFC 2396 and RFC 2732), nor that the resulting
local part is a legal NCName per the XML Namespaces specification.
if ((s == null) || s.equals("")) {
throw new IllegalArgumentException("invalid QName literal");
}
if (s.charAt(0) == '{") {
int i = s.indexOf('}");
if (i == -1) {
throw new IllegalArgumentException("invalid QName literal");
}
if (i == s.length() - 1) {
throw new IllegalArgumentException("invalid QName literal");
} else {
return new QName(s.substring(1, i), s.substring(i + 1));
}
} else {
return new QName(s);
}