private string ReadDefaultAttribute ()
{
ClearValueBuffer ();
TryExpandPERef ();
int quoteChar = ReadChar ();
if (quoteChar != '\'' && quoteChar != '\"')
throw NotWFError ("an attribute value was not quoted");
AppendValueChar (quoteChar);
while (PeekChar () != quoteChar) {
int ch = ReadChar ();
switch (ch)
{
case '<':
throw NotWFError ("attribute values cannot contain '<'");
case -1:
throw NotWFError ("unexpected end of file in an attribute value");
case '&':
AppendValueChar (ch);
if (PeekChar () == '#')
break;
// Check XML 1.0 section 3.1 WFC.
string entName = ReadName ();
Expect (';');
if (XmlChar.GetPredefinedEntity (entName) < 0) {
DTDEntityDeclaration entDecl =
DTD == null ? null : DTD.EntityDecls [entName];
if (entDecl == null || entDecl.SystemId != null)
// WFC: Entity Declared (see 4.1)
if (DTD.IsStandalone || (DTD.SystemId == null && !DTD.InternalSubsetHasPEReference))
throw NotWFError ("Reference to external entities is not allowed in attribute value.");
}
valueBuffer.Append (entName);
AppendValueChar (';');
break;
default:
AppendValueChar (ch);
break;
}
}
ReadChar (); // quoteChar
AppendValueChar (quoteChar);
return CreateValueString ();
}