diff --git a/Reporting/NUnitExecutionReport/NUnitExecutionReport.xslt b/Reporting/NUnitExecutionReport/NUnitExecutionReport.xslt
index 2f44b0876..4ccd43b13 100644
--- a/Reporting/NUnitExecutionReport/NUnitExecutionReport.xslt
+++ b/Reporting/NUnitExecutionReport/NUnitExecutionReport.xslt
@@ -8,7 +8,7 @@
exclude-result-prefixes="msxsl">
-
+
diff --git a/Reporting/StepDefinitionReport/StepDefinitionReport.xslt b/Reporting/StepDefinitionReport/StepDefinitionReport.xslt
index 45435beca..8349c35c5 100644
--- a/Reporting/StepDefinitionReport/StepDefinitionReport.xslt
+++ b/Reporting/StepDefinitionReport/StepDefinitionReport.xslt
@@ -7,7 +7,7 @@
exclude-result-prefixes="msxsl">
-
+
diff --git a/Reporting/XmlResourceResolver.cs b/Reporting/XmlResourceResolver.cs
index df8cf2e3a..7b8c9c928 100644
--- a/Reporting/XmlResourceResolver.cs
+++ b/Reporting/XmlResourceResolver.cs
@@ -10,18 +10,66 @@ public class XmlResourceResolver : XmlResolver
{
private ICredentials credentials;
- public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
+ public override Uri ResolveUri(Uri baseUri, string relativeUri)
+ {
+ if (baseUri == null)
+ {
+ if (relativeUri == null)
+ throw new ArgumentNullException ("Either baseUri or relativeUri are required.");
+
+ if (relativeUri.StartsWith ("resource:"))
+ {
+ return new Uri(relativeUri);
+ }
+ else
+ {
+ return base.ResolveUri(baseUri, relativeUri);
+ }
+ }
+
+ return base.ResolveUri(baseUri, relativeUri);
+ }
+
+ public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
{
string resourceName = absoluteUri.AbsolutePath.TrimStart(Path.AltDirectorySeparatorChar).Replace(Path.AltDirectorySeparatorChar, Type.Delimiter);
- string assemblyName = absoluteUri.Host;
-
- Assembly assembly = Assembly.Load(assemblyName);
- return new ResourceXmlReader(assembly, resourceName);
+ Assembly assembly = GetAssemblyFor(absoluteUri.Host);
+
+ if (ofObjectToReturn != null)
+ {
+ if (ofObjectToReturn == typeof(ResourceXmlReader) || ofObjectToReturn == typeof(XmlTextReader))
+ {
+ return new ResourceXmlReader(assembly, resourceName);
+ }
+ else if (ofObjectToReturn == typeof(Stream))
+ {
+ return assembly.GetManifestResourceStream(resourceName);
+ }
+ }
+
+ return assembly.GetManifestResourceStream(resourceName);
}
public override ICredentials Credentials
{
set { credentials = value; }
}
+
+ private static Assembly GetAssemblyFor(string host)
+ {
+ Assembly locatedAssembly = null;
+
+ foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ AssemblyName assemblyName = assembly.GetName();
+
+ if (!assemblyName.Name.Equals(host, StringComparison.CurrentCultureIgnoreCase))
+ continue;
+
+ locatedAssembly = assembly;
+ }
+
+ return locatedAssembly;
+ }
}
}
\ No newline at end of file
diff --git a/Reporting/XsltHelper.cs b/Reporting/XsltHelper.cs
index b4ce57683..6fbb2856e 100644
--- a/Reporting/XsltHelper.cs
+++ b/Reporting/XsltHelper.cs
@@ -40,7 +40,7 @@ public static void TransformHtml(XmlSerializer serializer, object report, Type r
var reportName = reportType.Name.Replace("Generator", "");
using (var xsltReader = new ResourceXmlReader(reportType, reportName + ".xslt"))
{
- xslt.Load(xsltReader, xsltSettings, resourceResolver);
+ xslt.Load(xsltReader, xsltSettings, resourceResolver);
}
var xmlOutputReader = new XmlTextReader(new StringReader(xmlOutputWriter.ToString()));
@@ -48,30 +48,12 @@ public static void TransformHtml(XmlSerializer serializer, object report, Type r
XsltArgumentList argumentList = new XsltArgumentList();
argumentList.AddParam("feature-language", "", generatorConfiguration.FeatureLanguage.Name);
argumentList.AddParam("tool-language", "", generatorConfiguration.ToolLanguage.Name);
- using (var outFileStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
+
+ using (var outFileStream = new FileStream(outputFilePath, FileMode.Create, FileAccess.Write))
+ using (var xmlTextWriter = new XmlTextWriter(outFileStream, Encoding.UTF8))
{
- xslt.Transform(xmlOutputReader, argumentList, outFileStream, resourceResolver);
+ xslt.Transform(xmlOutputReader, argumentList, xmlTextWriter, resourceResolver);
}
}
-
- static public void Transform(this XslCompiledTransform xslt, XmlReader input, XsltArgumentList arguments, Stream results, XmlResolver documentResolver)
- {
- //xslt.command.Execute(input, new XmlUrlResolver(), arguments, results);
-
- var command = xslt.GetType().GetField("command", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(xslt);
-
- var executeMethod = command.GetType().GetMethod("Execute", new Type[] { typeof(XmlReader), typeof(XmlResolver), typeof(XsltArgumentList), typeof(Stream) });
-
- try
- {
- executeMethod.Invoke(command, new object[] {input, documentResolver, arguments, results});
- }
- catch (TargetInvocationException invEx)
- {
- var ex = invEx.InnerException;
- ex.PreserveStackTrace();
- throw ex;
- }
- }
}
}