private void CompileDeclaration ()
{
switch(ReadChar ())
{
case '-':
Expect ('-');
// Only read, no store.
ReadComment ();
break;
case 'E':
switch(ReadChar ())
{
case 'N':
Expect ("TITY");
if (!SkipWhitespace ())
throw NotWFError (
"Whitespace is required after '<!ENTITY' in DTD entity declaration.");
LOOPBACK:
if (PeekChar () == '%') {
ReadChar ();
if (!SkipWhitespace ()) {
ExpandPERef ();
goto LOOPBACK;
} else {
// FIXME: Is this allowed? <!ENTITY % %name; ...>
// (i.e. Can PE name be replaced by another PE?)
TryExpandPERef ();
if (XmlChar.IsNameChar (PeekChar ()))
ReadParameterEntityDecl ();
else
throw NotWFError ("expected name character");
}
break;
}
DTDEntityDeclaration ent = ReadEntityDecl ();
if (DTD.EntityDecls [ent.Name] == null)
DTD.EntityDecls.Add (ent.Name, ent);
break;
case 'L':
Expect ("EMENT");
DTDElementDeclaration el = ReadElementDecl ();
DTD.ElementDecls.Add (el.Name, el);
break;
default:
throw NotWFError ("Syntax Error after '<!E' (ELEMENT or ENTITY must be found)");
}
break;
case 'A':
Expect ("TTLIST");
DTDAttListDeclaration atl = ReadAttListDecl ();
DTD.AttListDecls.Add (atl.Name, atl);
break;
case 'N':
Expect ("OTATION");
DTDNotationDeclaration not = ReadNotationDecl ();
DTD.NotationDecls.Add (not.Name, not);
break;
case '[':
// conditional sections
SkipWhitespace ();
TryExpandPERef ();
Expect ('I');
switch (ReadChar ()) {
case 'N':
Expect ("CLUDE");
ExpectAfterWhitespace ('[');
dtdIncludeSect++;
break;
case 'G':
Expect ("NORE");
ReadIgnoreSect ();
break;
}
break;
default:
throw NotWFError ("Syntax Error after '<!' characters.");
}
}