Can I use script blocks in XSL?
<xsl:template match="mytest">
Todo:
<h3>In progress...</h3>
'<%="hello-world" %>' CAN THIS WORK SOMEHOW
<span id="spnIcon" runat="server" class="fa-1x"></span>
</xsl:template>
Update
I'll explain a little more of what I'm trying to do. Simply, I'm trying to use XSL transform to dynamically generate an image.
So here's an illustration of the web page I'm trying to generate:
This is the XSL transform I've got (Note: I'm not using the XML part yet, I don't know if that might be causing issues):
using System;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
namespace WebApplication1
{
public partial class _default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string transform = GetXsl();
string input = GetXml();
StringWriter sw = new StringWriter();
using (XmlReader xrt = XmlReader.Create(new StringReader(transform)))
using (XmlReader xri = XmlReader.Create(new StringReader(input)))
using (XmlWriter xwo = XmlWriter.Create(sw))
{
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(xrt);
xslt.Transform(xri, xwo);
}
out11.InnerHtml = sw.ToString();
}
private string GetXml()
{
return
@"<?xml version='1.0' encoding='UTF-8'?>
<catalog>
<data id='1' option1='key1' option2='0' />
<data id='2' option1='' option2='1' />
</catalog>
";
}
private string GetXsl()
{
return
@"<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='/'>
<img src='<%= Class1.ImageName(""arg1"") %>' alt='alt text' />
</xsl:template>
</xsl:stylesheet>
";
}
}
}
The problem I'm having in the preceding code is in the GetXsl method (you may need to scroll down):
And here's the stack trace: