XSLT works in VS but not in ASP.NET runtime - fails with 'Cannot find script'
I am using xslt functions from MSXLT
<xsl:stylesheet version="1.0" xmlns开发者_StackOverflow社区:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
...
<xsl:value-of select="msxsl:format-date(/article/createDate, 'dd/MM')"/>
This works when debugging in VS, but when I run it in a web app, it fails: 'cannot find the script or external object that implements prefix msxsl'. Am I missing a reference in my web project?
Thanks for any help
Ryan
Ah, the trick is to use XSLTCompiledTransform, not XsltTranform in the C# code:
XslCompiledTransform myXslTrans = new XslCompiledTransform();
XsltSettings settings = new XsltSettings();
settings.EnableScript = true;
myXslTrans.Load(article.XslPath, settings, null);
Does the trick
精彩评论