/// <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 ) { Name = name; StartTagOptional = sto; EndTagOptional = eto; ContentModel = cm; _inclusions = inclusions; _exclusions = exclusions; }
void ParseModel( char cmt, ContentModel cm ) { // Called when part of the model is made up of the contents of a parameter entity var depth = cm.CurrentDepth; var ch = _current.SkipWhitespace(); while( ch != cmt || cm.CurrentDepth > depth ) // the entity must terminate while inside the content model. { if( ch == Entity.EOF ) { _current.Error( "Content Model was not closed" ); } switch( ch ) { case '%': var e = ParseParameterEntity( Cmterm ); PushEntity( _current.ResolvedUri, e ); ParseModel( Entity.EOF, cm ); PopEntity(); ch = _current.SkipWhitespace(); break; case '(': cm.PushGroup(); _current.ReadChar();// consume '(' ch = _current.SkipWhitespace(); break; case ')': ch = _current.ReadChar();// consume ')' if( Occurrences.Contains( ch ) ) { cm.AddOccurrence( ch ); _current.ReadChar(); } if( cm.PopGroup() < depth ) { _current.Error( "Parameter entity cannot close a paren outside it's own scope" ); } ch = _current.SkipWhitespace(); break; case '&': case '|': case ',': cm.AddConnector( ch ); _current.ReadChar(); // skip connector ch = _current.SkipWhitespace(); break; default: string token; if( ch == '#' ) { _current.ReadChar(); token = "#" + _current.ScanToken( _sb, Cmterm, true ); // since '#' is not a valid name character. } else { token = _current.ScanToken( _sb, Cmterm, true ); } token = token.ToUpperInvariant(); ch = _current.Lastchar; if( Occurrences.Contains( ch ) ) { cm.PushGroup(); cm.AddSymbol( token ); cm.AddOccurrence( ch ); cm.PopGroup(); _current.ReadChar(); // skip connector ch = _current.SkipWhitespace(); } else { cm.AddSymbol( token ); ch = _current.SkipWhitespace(); } break; } } }
private ContentModel ParseContentModel( char ch ) { var cm = new ContentModel(); switch( ch ) { case '(': _current.ReadChar(); ParseModel( ')', cm ); ch = _current.ReadChar(); if( Occurrences.Contains( ch ) ) { cm.AddOccurrence( ch ); _current.ReadChar(); } break; case '%': { var e = ParseParameterEntity( Dcterm ); PushEntity( _current.ResolvedUri, e ); cm = ParseContentModel( _current.Lastchar ); PopEntity(); // bugbug should be at EOF. } break; default: { var dc = ScanName( Dcterm ); cm.SetDeclaredContent( dc ); } break; } return cm; }