示例#1
0
        public static XmlQualifiedName ToQName(XmlReader reader, string qnamestr, out Exception innerEx)
        {
            innerEx = null;
            if (!XmlSchemaUtil.IsValidQName(qnamestr))
            {
                innerEx = new Exception(qnamestr + " is an invalid QName. Either name or namespace is not a NCName");
                return(XmlQualifiedName.Empty);
            }
            string[] array = qnamestr.Split(new char[]
            {
                ':'
            }, 2);
            string text;
            string name;

            if (array.Length == 2)
            {
                text = reader.LookupNamespace(array[0]);
                if (text == null)
                {
                    innerEx = new Exception("Namespace Prefix '" + array[0] + "could not be resolved");
                    return(XmlQualifiedName.Empty);
                }
                name = array[1];
            }
            else
            {
                text = reader.LookupNamespace(string.Empty);
                name = array[0];
            }
            return(new XmlQualifiedName(name, text));
        }