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.current.Lastchar; ch = this.current.SkipWhitespace(); while (ch != cmt || cm.CurrentDepth > depth) // the entity must terminate while inside the content model. { if (ch == Entity.EOF) { this.current.Error("Content Model was not closed"); } if (ch == '%') { Entity e = ParseParameterEntity(cmterm); PushEntity(this.current.ResolvedUri, e); ParseModel(Entity.EOF, cm); PopEntity(); ch = this.current.SkipWhitespace(); } else if (ch == '(') { cm.PushGroup(); this.current.ReadChar();// consume '(' ch = this.current.SkipWhitespace(); } else if (ch == ')') { ch = this.current.ReadChar();// consume ')' if (ch == '*' || ch == '+' || ch == '?') { cm.AddOccurrence(ch); ch = this.current.ReadChar(); } if (cm.PopGroup() < depth) { this.current.Error("Parameter entity cannot close a paren outside it's own scope"); } ch = this.current.SkipWhitespace(); } else if (ch == ',' || ch == '|' || ch == '&') { cm.AddConnector(ch); this.current.ReadChar(); // skip connector ch = this.current.SkipWhitespace(); } else { string token; if (ch == '#') { ch = this.current.ReadChar(); token = "#" + this.current.ScanToken(this.sb, cmterm, true); // since '#' is not a valid name character. } else { token = this.current.ScanToken(this.sb, cmterm, true); } token = token.ToUpper(); token = this.nameTable.Add(token);// atomize it. ch = this.current.Lastchar; if (ch == '?' || ch == '+' || ch == '*') { cm.PushGroup(); cm.AddSymbol(token); cm.AddOccurrence(ch); cm.PopGroup(); this.current.ReadChar(); // skip connector ch = this.current.SkipWhitespace(); } else { cm.AddSymbol(token); ch = this.current.SkipWhitespace(); } } } }