public XmlNameEntry Get(string prefix, string local, string ns,
                                bool atomic)
        {
            XmlNameEntry e = GetInternal(prefix, local, ns, atomic);

            return(e);
        }
Esempio n. 2
0
        public override bool Equals(object other)
        {
            XmlNameEntry e = other as XmlNameEntry;

            return(e != null && e.Hash == Hash &&
                   Object.ReferenceEquals(e.LocalName, LocalName) &&
                   Object.ReferenceEquals(e.NS, NS) &&
                   Object.ReferenceEquals(e.Prefix, Prefix));
        }
Esempio n. 3
0
        internal XmlAttribute(
            string prefix,
            string localName,
            string namespaceURI,
            XmlDocument doc,
            bool atomizedNames, bool checkNamespace) : base(doc)
        {
            if (!atomizedNames)
            {
                if (prefix == null)
                {
                    prefix = String.Empty;
                }
                if (namespaceURI == null)
                {
                    namespaceURI = String.Empty;
                }
            }

            // Prefix "xml" should be also checked (http://www.w3.org/XML/xml-names-19990114-errata#NE05)
            // but MS.NET ignores such case
            if (checkNamespace)
            {
                if (prefix == "xmlns" || (prefix == "" && localName == "xmlns"))
                {
                    if (namespaceURI != XmlNamespaceManager.XmlnsXmlns)
                    {
                        throw new ArgumentException("Invalid attribute namespace for namespace declaration.");
                    }
                    else if (prefix == "xml" && namespaceURI != XmlNamespaceManager.XmlnsXml)
                    {
                        throw new ArgumentException("Invalid attribute namespace for namespace declaration.");
                    }
                }
            }

            if (!atomizedNames)
            {
                // There are no means to identify the DOM is
                // namespace-aware or not, so we can only
                // check Name validity.
                if (prefix != "" && !XmlChar.IsName(prefix))
                {
                    throw new ArgumentException("Invalid attribute prefix.");
                }
                else if (!XmlChar.IsName(localName))
                {
                    throw new ArgumentException("Invalid attribute local name.");
                }

                prefix       = doc.NameTable.Add(prefix);
                localName    = doc.NameTable.Add(localName);
                namespaceURI = doc.NameTable.Add(namespaceURI);
            }
            name = doc.NameCache.Add(prefix, localName, namespaceURI, true);
        }
        public XmlNameEntry Add(string prefix, string local, string ns,
                                bool atomic)
        {
            if (!atomic)
            {
                prefix = nameTable.Add(prefix);
                local  = nameTable.Add(local);
                ns     = nameTable.Add(ns);
            }
            XmlNameEntry e = GetInternal(prefix, local, ns, true);

            if (e == null)
            {
                e         = new XmlNameEntry(prefix, local, ns);
                table [e] = e;
            }
            return(e);
        }
Esempio n. 5
0
        internal XmlElement(
            string prefix,
            string localName,
            string namespaceURI,
            XmlDocument doc,
            bool atomizedNames) : base(doc)
        {
            if (!atomizedNames)
            {
                if (prefix == null)
                {
                    prefix = String.Empty;
                }
                if (namespaceURI == null)
                {
                    namespaceURI = String.Empty;
                }

                XmlConvert.VerifyName(localName);

                prefix       = doc.NameTable.Add(prefix);
                localName    = doc.NameTable.Add(localName);
                namespaceURI = doc.NameTable.Add(namespaceURI);
            }
            name = doc.NameCache.Add(prefix, localName, namespaceURI, true);

            if (doc.DocumentType != null)
            {
                DTDAttListDeclaration attlist = doc.DocumentType.DTD.AttListDecls [localName];
                if (attlist != null)
                {
                    for (int i = 0; i < attlist.Definitions.Count; i++)
                    {
                        DTDAttributeDefinition def = attlist [i];
                        if (def.DefaultValue != null)
                        {
                            SetAttribute(def.Name, def.DefaultValue);
                            Attributes [def.Name].SetDefault();
                        }
                    }
                }
            }
        }