":localonly" //error?
Error.
"prefixonly:" //error?
Error.
":" //should be caught by previous logic
+1
"nocolon" //assume ns="" or ns=element.getNamespace()
The second choice wouldn't be element.getNamespace(), it would be the
default namepace. Both choices are valid depending on context, which is
why I believe there was a switch on the Axis1 version of this logic
(something like "enableDefaultNS" or something). Recommend a switch,
and default to doing default namespace logic. So:
public QName resolveQName(String text) {
return resolveQName(text, true);
}
public QName resolveQName(String text, boolean useDefaultNS) {
int colon = text.indexOf(':');
String prefix;
if (colon == 0) return null;
if (colon < 0) {
// No prefix - behave appropriately
if (useDefaultNS) {
// Assuming findNamespace(null, "") returns
// the default ns below...
prefix = "";
} else {
return new QName(text);
}
} else {
prefix = text.substring(0, colon);
}
String local = text.substring(colon + 1);
//TODO: what if local=="" ?
OMNamespace namespace = findNamespace(null, prefix);
if (namespace == null) {
return null;
}
return new QName(namespace.getName(), local, prefix);
}
--Glen