internal static XMLName Parse(XMLLib lib, Context cx, string name) { if (name == null) { throw new ArgumentNullException("name"); } int l = name.Length; if (l != 0) { char firstChar = name [0]; if (firstChar == '*') { if (l == 1) { return(FormStar()); } } else if (firstChar == '@') { XMLName xmlName = FormProperty("", name.Substring(1)); xmlName.IsAttributeName = true; return(xmlName); } } String uri = lib.GetDefaultNamespaceURI(cx); return(XMLName.FormProperty(uri, name)); }
internal XMLName toQualifiedName(Context cx, Object namespaceValue, Object nameValue) { // This is duplication of constructQName(cx, namespaceValue, nameValue) // but for XMLName String uri; String localName; if (nameValue is QName) { QName qname = (QName)nameValue; localName = qname.LocalName; } else { localName = ScriptConvert.ToString(nameValue); } Namespace ns; if (namespaceValue == Undefined.Value) { if ("*".Equals(localName)) { ns = null; } else { ns = GetDefaultNamespace(cx); } } else if (namespaceValue == null) { ns = null; } else if (namespaceValue is Namespace) { ns = (Namespace)namespaceValue; } else { ns = Namespace.Parse(this, cx, namespaceValue); } if (ns == null) { uri = null; } else { uri = ns.Uri; } return(XMLName.FormProperty(uri, localName)); }
internal static XMLName Parse(XMLLib lib, Context cx, Object value) { XMLName result; if (value is XMLName) { result = (XMLName)value; } else if (value is String) { String str = (String)value; long test = ScriptRuntime.testUint32String(str); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); result = null; } else { result = Parse(lib, cx, str); } } else if (CliHelper.IsNumber(value)) { double d = ScriptConvert.ToNumber(value); long l = (long)d; if (l == d && 0 <= l && l <= 0xFFFFFFFFL) { ScriptRuntime.storeUint32Result(cx, l); result = null; } else { throw XMLLib.BadXMLName(value); } } else if (value is QName) { QName qname = (QName)value; String uri = qname.Uri; bool number = false; result = null; if (uri != null && uri.Length == 0) { // Only in this case qname.toString() can resemble uint32 long test = ScriptRuntime.testUint32String(uri); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); number = true; } } if (!number) { result = XMLName.FormProperty(uri, qname.LocalName); } } else if (value is Boolean || value == Undefined.Value || value == null) { throw XMLLib.BadXMLName(value); } else { String str = ScriptConvert.ToString(value); long test = ScriptRuntime.testUint32String(str); if (test >= 0) { ScriptRuntime.storeUint32Result(cx, test); result = null; } else { result = Parse(lib, cx, str); } } return(result); }