This question already has an answer here:
I am writing an XSLT transformation to translate a XML credit report.
When I run the following code I am getting "Illegal Characters in Path" error. Not sure what I am missing. I want this method to return a HTML string.
I have tested the XSLT transform on the XML and it works. This code fails on the transform.Load function with the "Illegal Characters in Path" error.
What am I missing here?
private string FormatCreditReport(string inputXml)
{
var xsltTransform = new XslCompiledTransform();
var webRootPath = HostingEnvironment.ApplicationPhysicalPath;
var path = webRootPath
+ "XSLT_Stylesheets"
+ Path.DirectorySeparatorChar
+ "CreditReportTransform.xslt";
var xsltTemplate = File.ReadAllText(path);
xsltTransform.Load(xsltTemplate);
StringWriter results = new StringWriter();
using (var reader = XmlReader.Create(new StringReader(inputXml)))
{
xsltTransform.Transform(reader, null, results);
}
return results.ToString();
}
XSLT Document:
<xsl:template match="/">
<html>
<body>
<table border ="1">
<tr>
<th><h2>Credit File</h2></th>
</tr>
<tr></tr>
<tr>
<td>File Since Date</td>
<td><xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/FileSinceDate"/></td>
</tr>
<tr>
<td>Date of Last Activity</td>
<td><xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/DateOfLastActivity"/></td>
</tr>
<tr>
<td>Date of Request</td>
<td><xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/CreditFile/DateOfRequest"/></td>
</tr>
<tr></tr>
<tr>
<th><h2>Subject</h2></th>
</tr>
<tr>
<td>Last Name</td>
<td><xsl:value-of select="EfxTransmit/EfxReport/USConsumerCreditReports/USConsumerCreditReport/USHeader/Subject/LastName"/></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
</xsl:template>
I was bad and posted this question a second time, but someone was able to give me an answer so here it is....
should have been
and all is perfect.