private void ReadTextDeclaration ()
{
if (!currentInput.AllowTextDecl)
throw NotWFError ("Text declaration cannot appear in this state.");
currentInput.AllowTextDecl = false;
SkipWhitespace ();
// version decl
if (PeekChar () == 'v') {
Expect ("version");
ExpectAfterWhitespace ('=');
SkipWhitespace ();
int quoteChar = ReadChar ();
char [] expect1_0 = new char [3];
int versionLength = 0;
switch (quoteChar) {
case '\'':
case '"':
while (PeekChar () != quoteChar) {
if (PeekChar () == -1)
throw NotWFError ("Invalid version declaration inside text declaration.");
else if (versionLength == 3)
throw NotWFError ("Invalid version number inside text declaration.");
else {
expect1_0 [versionLength] = (char) ReadChar ();
versionLength++;
if (versionLength == 3 && new String (expect1_0) != "1.0")
throw NotWFError ("Invalid version number inside text declaration.");
}
}
ReadChar ();
SkipWhitespace ();
break;
default:
throw NotWFError ("Invalid version declaration inside text declaration.");
}
}
if (PeekChar () == 'e') {
Expect ("encoding");
ExpectAfterWhitespace ('=');
SkipWhitespace ();
int quoteChar = ReadChar ();
switch (quoteChar) {
case '\'':
case '"':
while (PeekChar () != quoteChar)
if (ReadChar () == -1)
throw NotWFError ("Invalid encoding declaration inside text declaration.");
ReadChar ();
SkipWhitespace ();
break;
default:
throw NotWFError ("Invalid encoding declaration inside text declaration.");
}
// Encoding value should be checked inside XmlInputStream.
}
else
throw NotWFError ("Encoding declaration is mandatory in text declaration.");
Expect ("?>");
}