Defines the content model for an element.
Ejemplo n.º 1
0
        private void ParseModel(char cmt, ContentModel cm)
        {
            // Called when part of the model is made up of the contents of a parameter entity
            int depth = cm.CurrentDepth;
            char ch = this.m_current.Lastchar;
            ch = this.m_current.SkipWhitespace();
            while (ch != cmt || cm.CurrentDepth > depth) // the entity must terminate while inside the content model.
            {
                if (ch == Entity.EOF)
                {
                    this.m_current.Error("Content Model was not closed");
                }
                if (ch == '%')
                {
                    Entity e = this.ParseParameterEntity(cmterm);
                    this.PushEntity(this.m_current.ResolvedUri, e);
                    this.ParseModel(Entity.EOF, cm);
                    this.PopEntity();
                    ch = this.m_current.SkipWhitespace();
                }
                else if (ch == '(')
                {
                    cm.PushGroup();
                    this.m_current.ReadChar(); // consume '('
                    ch = this.m_current.SkipWhitespace();
                }
                else if (ch == ')')
                {
                    ch = this.m_current.ReadChar(); // consume ')'
                    if (ch == '*' || ch == '+' || ch == '?')
                    {
                        cm.AddOccurrence(ch);
                        ch = this.m_current.ReadChar();
                    }
                    if (cm.PopGroup() < depth)
                    {
                        this.m_current.Error("Parameter entity cannot close a paren outside it's own scope");
                    }
                    ch = this.m_current.SkipWhitespace();
                }
                else if (ch == ',' || ch == '|' || ch == '&')
                {
                    cm.AddConnector(ch);
                    this.m_current.ReadChar(); // skip connector
                    ch = this.m_current.SkipWhitespace();
                }
                else
                {
                    string token;
                    if (ch == '#')
                    {
                        ch = this.m_current.ReadChar();
                        token = "#" + this.m_current.ScanToken(this.m_sb, cmterm, true); // since '#' is not a valid name character.
                    }
                    else
                    {
                        token = this.m_current.ScanToken(this.m_sb, cmterm, true);
                    }

                    token = token.ToUpperInvariant();
                    ch = this.m_current.Lastchar;
                    if (ch == '?' || ch == '+' || ch == '*')
                    {
                        cm.PushGroup();
                        cm.AddSymbol(token);
                        cm.AddOccurrence(ch);
                        cm.PopGroup();
                        this.m_current.ReadChar(); // skip connector
                        ch = this.m_current.SkipWhitespace();
                    }
                    else
                    {
                        cm.AddSymbol(token);
                        ch = this.m_current.SkipWhitespace();
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 ///   Initialises a new element declaration instance.
 /// </summary>
 /// <param name = "name">The name of the element.</param>
 /// <param name = "sto">Whether the start tag is optional.</param>
 /// <param name = "eto">Whether the end tag is optional.</param>
 /// <param name = "cm">The <see cref = "ContentModel" /> of the element.</param>
 /// <param name = "inclusions"></param>
 /// <param name = "exclusions"></param>
 public ElementDecl(string name, bool sto, bool eto, ContentModel cm, string[] inclusions, string[] exclusions)
 {
     this.m_name = name;
     this.m_startTagOptional = sto;
     this.m_endTagOptional = eto;
     this.m_contentModel = cm;
     this.m_inclusions = inclusions;
     this.m_exclusions = exclusions;
 }
Ejemplo n.º 3
0
 private ContentModel ParseContentModel(char ch)
 {
     ContentModel cm = new ContentModel();
     if (ch == '(')
     {
         this.m_current.ReadChar();
         this.ParseModel(')', cm);
         ch = this.m_current.ReadChar();
         if (ch == '?' || ch == '+' || ch == '*')
         {
             cm.AddOccurrence(ch);
             this.m_current.ReadChar();
         }
     }
     else if (ch == '%')
     {
         Entity e = this.ParseParameterEntity(dcterm);
         this.PushEntity(this.m_current.ResolvedUri, e);
         cm = this.ParseContentModel(this.m_current.Lastchar);
         this.PopEntity(); // bugbug should be at EOF.
     }
     else
     {
         string dc = this.ScanName(dcterm);
         cm.SetDeclaredContent(dc);
     }
     return cm;
 }