public String qName2String(QName qName,boolean writeNS){
  String prefix=null;
  String namespaceURI=qName.getNamespace();
  String localPart=qName.getLocalPart();
  if (localPart != null && localPart.length() > 0) {
    int index=localPart.indexOf(':');
    if (index != -1) {
      prefix=localPart.substring(0,index);
      if (prefix.length() > 0 && !prefix.equals("urn")) {
        registerPrefixForURI(prefix,namespaceURI);
        localPart=localPart.substring(index + 1);
      }
 else {
        prefix=null;
      }
    }
    localPart=getLastLocalPart(localPart);
  }
  if (namespaceURI.length() == 0) {
    if (writeNS) {
      String defaultNS=nsStack.getNamespaceURI("");
      if (defaultNS != null && defaultNS.length() > 0) {
        registerPrefixForURI("","");
      }
    }
  }
 else {
    prefix=getPrefixForURI(namespaceURI,qName.getPreferredPrefix());
  }
  if ((prefix == null) || (prefix.length() == 0))   return localPart;
  return prefix + ':' + localPart;
}

public String qName2String ( QName qName , boolean writeNS ) { String prefix = null ; String namespaceURI = qName . getNamespace ( ) ; String localPart = qName . getLocalPart ( ) ; if ( localPart != null && localPart . length ( ) > 0 ) { int index = localPart . indexOf ( ':' ) ; if ( index != - 1 ) { prefix = localPart . substring ( 0 , index ) ; if ( prefix . length ( ) > 0 && ! prefix . equals ( "urn" ) ) { registerPrefixForURI ( prefix , namespaceURI ) ; localPart = localPart . substring ( index + 1 ) ; } else { prefix = null ; } } localPart = getLastLocalPart ( localPart ) ; } if ( namespaceURI . length ( ) == 0 ) { if ( writeNS ) { String defaultNS = nsStack . getNamespaceURI ( "" ) ; if ( defaultNS != null && defaultNS . length ( ) > 0 ) { registerPrefixForURI ( "" , "" ) ; } } } else { prefix = getPrefixForURI ( namespaceURI , qName . getPreferredPrefix ( ) ) ; } if ( ( prefix == null ) || ( prefix . length ( ) == 0 ) ) return localPart ; return prefix + ':' + localPart ; }
convert qname to a string of the form < prefix > : < localpart >
