Hmm,

I like to name this method as getTextAsQName().

Actually I was initialy confused what you need to do, but after the code
snippet from Steve I understood the real requirement.

I can't understand why you are passing a String to the resolveQName
method if this methid is *in* the OMElement. I think the requirement is
to get the text in an OMElement as a QName. So, IMHO,
OMElement.getTextAsQName() is much better.


Glen Daniels wrote:

>> ":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
>
>

Reply via email to