docs: QName constructQName(XMLLibImpl lib, Context cx, Object namespace, Object name) {
          String nameString = null;
          if (name instanceof QName) {
              if (namespace == Undefined.instance) {
                  return (QName)name;
              } else {
                  nameString = ((QName)name).localName();
              }
          }
          if (name == Undefined.instance) {
              nameString = "";
          } else {
              nameString = ScriptRuntime.toString(name);
          }
  
          if (namespace == Undefined.instance) {
              if ("*".equals(nameString)) {
                  namespace = null;
              } else {
                  namespace = lib.getDefaultNamespace(cx);
              }
          }
          Namespace namespaceNamespace = null;
          if (namespace == null) {
              //    leave as null
          } else if (namespace instanceof Namespace) {
              namespaceNamespace = (Namespace)namespace;
          } else {
              namespaceNamespace = lib.newNamespace(ScriptRuntime.toString(namespace));
          }
          String q_localName = nameString;
          String q_uri;
          String q_prefix;
          if (namespace == null) {
              q_uri = null;
              q_prefix = null;    //    corresponds to undefined; see QName class
          } else {
              q_uri = namespaceNamespace.uri();
              q_prefix = namespaceNamespace.prefix();
          }
          return newQName(lib, q_uri, q_localName, q_prefix);
      }