[Mono-bugs] [Bug 72942][Nor] Changed - XmlUrlResolver is not used properly
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 24 Feb 2005 00:30:47 -0500 (EST)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by atsushi@ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=72942
--- shadow/72942 2005-02-23 23:55:38.000000000 -0500
+++ shadow/72942.tmp.26319 2005-02-24 00:30:47.000000000 -0500
@@ -1,17 +1,17 @@
Bug#: 72942
Product: Mono: Class Libraries
Version: 1.1
-OS:
+OS: unknown
OS Details:
Status: NEW
Resolution:
-Severity:
+Severity: Unknown
Priority: Normal
Component: Sys.XML
-AssignedTo: mono-bugs@ximian.com
+AssignedTo: atsushi@ximian.com
ReportedBy: tberman@off.net
QAContact: mono-bugs@ximian.com
TargetMilestone: ---
URL:
Cc:
Summary: XmlUrlResolver is not used properly
@@ -21,6 +21,73 @@
just untar, cd, and ./test
------- Additional Comments From tberman@off.net 2005-02-23 23:55 -------
Created an attachment (id=14362)
resolverbug.tar
+
+------- Additional Comments From atsushi@ximian.com 2005-02-24 00:30 -------
+Some fixes in test.cs and more tricky patterns in the code.
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Net;
+using System.Xml;
+using System.Xml.Xsl;
+
+public class ResolverTest {
+ public static void Main (string[] args) {
+ XslTransform transform = new XslTransform ();
+ transform.XmlResolver = new MyResolver (1);
+ MyResolver resolver = new MyResolver (2);
+
+ XmlDocument document = new XmlDocument ();
+ document.LoadXml ("<foo/>");
+
+// transform.Load ("http://example.com/test1.xsl", resolver);
+ transform.Load ("test1.xsl", new NullUrlResolver ());
+ }
+}
+
+class NullUrlResolver : XmlResolver {
+
+ public override ICredentials Credentials {
+ set { }
+ }
+
+ public override Uri ResolveUri (Uri baseUri, string relativePath)
+ {
+ Console.WriteLine ("NullUrlResolver.ResolveUri(). uri is {0},
+relative path is {1}", baseUri, relativePath);
+ return null;
+ }
+
+ public override object GetEntity (Uri uri, string role, Type ret)
+ {
+ Console.WriteLine ("NullUrlResolver.GetEntity(). uri is " + uri);
+ return null;
+ }
+}
+
+class MyResolver : XmlUrlResolver {
+ private static string prefix = "http://example.com/";
+ int id;
+
+ public MyResolver (int id)
+ {
+ this.id = id;
+ }
+
+ public override object GetEntity (System.Uri uri, string role,
+System.Type type) {
+ System.Console.WriteLine ("GetEntity called from MyResolver {0}. Uri
+is {1}", id, uri);
+
+ string href = uri.AbsoluteUri.Substring (prefix.Length);
+// Stream s = Assembly.GetExecutingAssembly
+().GetManifestResourceStream (href);
+ Stream s = new FileStream (href, FileMode.Open);
+ return s;
+ }
+}
+