Sgml.ContentModel.SetDeclaredContent C# (CSharp) Method

SetDeclaredContent() public method

Sets the contained content for the content model.
public SetDeclaredContent ( string dc ) : void
dc string The text specified the permissible declared child content.
return void
        public void SetDeclaredContent(string dc)
        {
            // TODO: Validate that this can never combine with nexted groups?
            switch (dc)
            {
                case "EMPTY":
                    this.m_declaredContent = DeclaredContent.EMPTY;
                    break;
                case "RCDATA":
                    this.m_declaredContent = DeclaredContent.RCDATA;
                    break;
                case "CDATA":
                    this.m_declaredContent = DeclaredContent.CDATA;
                    break;
                default:
                    throw new SgmlParseException(string.Format(CultureInfo.CurrentUICulture, "Declared content type '{0}' is not supported", dc));
            }
        }

Usage Example

Example #1
0
 private ContentModel ParseContentModel(char ch)
 {
     ContentModel cm = new ContentModel();
     if (ch == '(') 
     {
         this.m_current.ReadChar();
         ParseModel(')', cm);
         ch = this.m_current.ReadChar();
         if (ch == '?' || ch == '+' || ch == '*') 
         {
             cm.AddOccurrence(ch);
             this.m_current.ReadChar();
         }
     } 
     else if (ch == '%') 
     {
         Entity e = ParseParameterEntity(SgmlDtd.dcterm);
         PushEntity(this.m_current.ResolvedUri, e);
         cm = ParseContentModel(this.m_current.Lastchar);
         PopEntity(); // bugbug should be at EOF.
     }
     else
     {
         string dc = ScanName(SgmlDtd.dcterm);
         cm.SetDeclaredContent(dc);
     }
     return cm;
 }