Skip to content

Commit 4b6cfb2

Browse files
committed
basics of external xslt passing
1 parent 96ad82f commit 4b6cfb2

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

Reporting/LocalUrlResolver.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
using System.Xml;
3+
4+
namespace TechTalk.SpecFlow.Reporting
5+
{
6+
class LocalUrlResolver : XmlUrlResolver
7+
{
8+
public override Uri ResolveUri(Uri baseUri, string relativeUri)
9+
{
10+
if (baseUri != null)
11+
return base.ResolveUri(baseUri, relativeUri);
12+
return base.ResolveUri(new Uri("http://mypath/"), relativeUri);
13+
}
14+
}
15+
}

Reporting/TechTalk.SpecFlow.Reporting.csproj

+9-3
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,12 @@
8484
<Compile Include="XsltHelper.cs" />
8585
</ItemGroup>
8686
<ItemGroup>
87-
<EmbeddedResource Include="Common\Common.xslt" />
88-
<EmbeddedResource Include="Common\GherkinElements.xslt" />
89-
<EmbeddedResource Include="NUnitExecutionReport\NUnitExecutionReport.xslt" />
87+
<EmbeddedResource Include="..\..\SpecFlow-Examples\BowlingKata\BowlingKata-Nunit\Bowling.Specflow\bin\Debug\Common.xslt">
88+
<Link>Common\Common.xslt</Link>
89+
</EmbeddedResource>
90+
<EmbeddedResource Include="..\..\SpecFlow-Examples\BowlingKata\BowlingKata-Nunit\Bowling.Specflow\bin\Debug\GherkinElements.xslt">
91+
<Link>Common\GherkinElements.xslt</Link>
92+
</EmbeddedResource>
9093
<EmbeddedResource Include="StepDefinitionReport\StepDefinitionReport.xslt" />
9194
</ItemGroup>
9295
<ItemGroup>
@@ -104,6 +107,9 @@
104107
<Link>Common\Languages.xml</Link>
105108
</EmbeddedResource>
106109
</ItemGroup>
110+
<ItemGroup>
111+
<EmbeddedResource Include="NUnitExecutionReport\NUnitExecutionReport.xslt" />
112+
</ItemGroup>
107113
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
108114
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
109115
Other similar extension points exist, see Microsoft.Common.targets.

Reporting/XsltHelper.cs

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,23 @@ public static void TransformHtml(XmlSerializer serializer, object report, Type r
3333
serializer.Serialize(xmlOutputWriter, report);
3434

3535
XslCompiledTransform xslt = new XslCompiledTransform();
36-
3736
var xsltSettings = new XsltSettings(true, false);
38-
var resourceResolver = new XmlResourceResolver();
37+
XmlResolver resourceResolver;
3938

4039
var reportName = reportType.Name.Replace("Generator", "");
4140

4241
if (!string.IsNullOrEmpty(xsltFile))
4342
{
4443
XmlDocument document = new XmlDocument();
4544
document.Load(xsltFile);
46-
xslt.Load(document);
45+
resourceResolver = new LocalUrlResolver();
46+
xslt.Load(document, xsltSettings, resourceResolver);
4747
}
4848
else
4949
{
5050
using (var xsltReader = new ResourceXmlReader(reportType, reportName + ".xslt"))
5151
{
52+
resourceResolver = new XmlResourceResolver();
5253
xslt.Load(xsltReader, xsltSettings, resourceResolver);
5354
}
5455
}

0 commit comments

Comments
 (0)