private void ResolveInternalEntityReplacementText (DTDEntityBase decl)
{
string value = decl.LiteralEntityValue;
int len = value.Length;
ClearValueBuffer ();
for (int i = 0; i < len; i++) {
int ch = value [i];
int end = 0;
string name;
switch (ch) {
case '&':
i++;
end = value.IndexOf (';', i);
if (end < i + 1)
throw new XmlException (decl, decl.BaseURI, "Invalid reference markup.");
// expand charref
if (value [i] == '#') {
i++;
ch = GetCharacterReference (decl, value, ref i, end);
if (XmlChar.IsInvalid (ch))
throw NotWFError ("Invalid character was used to define parameter entity.");
} else {
name = value.Substring (i, end - i);
if (!XmlChar.IsName (name))
throw NotWFError (String.Format ("'{0}' is not a valid entity reference name.", name));
// don't expand "general" entity.
AppendValueChar ('&');
valueBuffer.Append (name);
AppendValueChar (';');
i = end;
break;
}
if (XmlChar.IsInvalid (ch))
throw new XmlException (decl, decl.BaseURI, "Invalid character was found in the entity declaration.");
AppendValueChar (ch);
break;
case '%':
i++;
end = value.IndexOf (';', i);
if (end < i + 1)
throw new XmlException (decl, decl.BaseURI, "Invalid reference markup.");
name = value.Substring (i, end - i);
valueBuffer.Append (GetPEValue (name));
i = end;
break;
default:
AppendValueChar (ch);
break;
}
}
decl.ReplacementText = CreateValueString ();
ClearValueBuffer ();
}