예제 #1
0
파일: Sgml.cs 프로젝트: JasonSoft/JasonSoft
 // 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;
 }
예제 #2
0
파일: Sgml.cs 프로젝트: JasonSoft/JasonSoft
 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);
 }
예제 #3
0
파일: Sgml.cs 프로젝트: JasonSoft/JasonSoft
 public bool CanContain(string name, SgmlDtd dtd)
 {
     if (DeclaredContent != DeclaredContent.Default)
         return false; // empty or text only node.
     return Model.CanContain(name, dtd);
 }
예제 #4
0
파일: Sgml.cs 프로젝트: JasonSoft/JasonSoft
        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 assembly = Assembly.GetExecutingAssembly();
                        string name = "JasonSoft.EmbeddedResource.xhtml-strict.dtd";
                        StreamReader sr = new StreamReader(assembly.GetManifestResourceStream(name));
                        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");
                }

            }
        }
예제 #5
0
파일: Sgml.cs 프로젝트: JasonSoft/JasonSoft
 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;
 }