public bool CanContain(string name, SgmlDtd dtd)
 {            
     // return true if this element is allowed to contain the given element.
     if (Exclusions != null) 
     {
         foreach (string s in Exclusions) 
         {
             if ((object)s == (object)name) // XmlNameTable optimization
                 return false;
         }
     }
     if (Inclusions != null) 
     {
         foreach (string s in Inclusions) 
         {
             if ((object)s == (object)name) // XmlNameTable optimization
                 return true;
         }
     }
     return ContentModel.CanContain(name, dtd);
 }
 public static SgmlDtd Parse(Uri baseUri, string name, string pubid, TextReader input, string subset, string proxy, XmlNameTable nt) {
     SgmlDtd dtd = new SgmlDtd(name, nt);
     dtd.PushEntity(baseUri, new Entity(dtd.Name, baseUri, input, proxy));
     if (subset != null && subset != "") {
         dtd.PushEntity(baseUri, new Entity(name, subset));
     }
     try {
         dtd.Parse();
     } 
     catch (Exception e) {
         throw new Exception(e.Message + dtd.current.Context());
     }           
     return dtd;
 }
 public bool CanContain(string name, SgmlDtd dtd)
 {
     if (DeclaredContent != DeclaredContent.Default)
         return false; // empty or text only node.
     return Model.CanContain(name, dtd);
 }
 // Rough approximation - this is really assuming an "Or" group
 public bool CanContain(string name, SgmlDtd dtd)
 {
     // Do a simple search of members.
     foreach (object obj in Members) 
     {
         if (obj is String) 
         {
             if (obj == (object)name) // XmlNameTable optimization
                 return true;
         } 
     }
     // didn't find it, so do a more expensive search over child elements
     // that have optional start tags and over child groups.
     foreach (object obj in Members) 
     {
         if (obj is String) 
         {
             string s = (string)obj;
             ElementDecl e = dtd.FindElement(s);
             if (e != null) 
             {
                 if (e.StartTagOptional) 
                 {
                     // tricky case, the start tag is optional so element may be
                     // allowed inside this guy!
                     if (e.CanContain(name, dtd))
                         return true;
                 }
             }
         } 
         else 
         {
             Group m = (Group)obj;
             if (m.CanContain(name, dtd)) 
                 return true;
         }
     }
     return false;
 }
        private void LazyLoadDtd(Uri baseUri) {
            if (this.dtd == null) {
                if (this.syslit == null || this.syslit == "") {
                    if (this.docType != null && StringUtilities.EqualsIgnoreCase(this.docType, "html")) {
                        Assembly a = typeof(SgmlReader).Assembly;
                        string name = a.FullName.Split(',')[0]+".Xml.Sgml.Html.dtd";
                        Stream stm = a.GetManifestResourceStream(name);
                        if (stm != null){
                            StreamReader sr = new StreamReader(stm);
                            this.dtd = SgmlDtd.Parse(baseUri, "HTML", null, sr, null, this.proxy, this.nametable);
                        }
                    }
                } else {
                    if (baseUri != null) {
                        baseUri = new Uri(baseUri, this.syslit);
                    } else if (this.baseUri != null) {
                        baseUri = new Uri(this.baseUri, this.syslit);
                    } else {
                        baseUri = new Uri(new Uri(Directory.GetCurrentDirectory()+"\\"), this.syslit);
                    }
                    this.dtd = SgmlDtd.Parse(baseUri, this.docType, this.pubid, baseUri.AbsoluteUri, this.subset, this.proxy, this.nametable);
                }

                if (this.dtd != null && this.dtd.Name != null){
                    switch (this.CaseFolding){
                        case CaseFolding.ToUpper:
                            this.rootElementName = this.dtd.Name.ToUpper();
                            break;
                        case CaseFolding.ToLower:
                            this.rootElementName = this.dtd.Name.ToLower();
                            break;
                        default:
                            this.rootElementName = this.dtd.Name;
                            break;
                    }
                    this.isHtml = StringUtilities.EqualsIgnoreCase(this.dtd.Name, "html");
                }

            }
        }