private void PushParserInput (string url)
{
Uri baseUri = null;
try {
if (DTD.BaseURI != null && DTD.BaseURI.Length > 0)
baseUri = new Uri (DTD.BaseURI);
} catch (UriFormatException) {
}
Uri absUri = url != null && url.Length > 0 ?
DTD.Resolver.ResolveUri (baseUri, url) : baseUri;
string absPath = absUri != null ? absUri.ToString () : String.Empty;
foreach (XmlParserInput i in parserInputStack.ToArray ()) {
if (i.BaseURI == absPath)
throw NotWFError ("Nested inclusion is not allowed: " + url);
}
parserInputStack.Push (currentInput);
Stream s = null;
MemoryStream ms = new MemoryStream ();
try {
s = DTD.Resolver.GetEntity (absUri, null, typeof (Stream)) as Stream;
int size;
byte [] buf = new byte [4096];
do {
size = s.Read (buf, 0, buf.Length);
ms.Write (buf, 0, size);
} while (size > 0);
s.Close ();
ms.Position = 0;
currentInput = new XmlParserInput (new XmlStreamReader (ms), absPath);
} catch (Exception ex) { // FIXME: (wishlist) Bad exception catch ;-(
if (s != null)
s.Close ();
int line = currentInput == null ? 0 : currentInput.LineNumber;
int col = currentInput == null ? 0 : currentInput.LinePosition;
string bu = (currentInput == null) ? String.Empty : currentInput.BaseURI;
HandleError (new XmlSchemaException ("Specified external entity not found. Target URL is " + url + " .",
line, col, null, bu, ex));
currentInput = new XmlParserInput (new StringReader (String.Empty), absPath);
}
}