开发者

XSLT works in VS but not in ASP.NET runtime - fails with 'Cannot find script'

开发者 https://www.devze.com 2023-04-05 04:22 出处:网络
I am using xslt functions from MSXLT <xsl:stylesheet version=\"1.0\" xmlns开发者_StackOverflow社区:xsl=\"http://www.w3.org/1999/XSL/Transform\"

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号