在 Umbraco XSLT 中使用自定义类文件
我正在尝试在 XSLT 代码中引用自定义类文件。我将它作为 DLL 文件部署到 /Bin 目录。
继续出现此错误:
System.Xml.Xsl.XslTransformException:找不到实现前缀“urn:sso”的脚本或外部对象。
CS 文件声明:
namespace SSOUtilities
{
public class sso
XSLT 参考:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:sso="urn:sso"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour sso">
config/xsltExtensions.config 声明:
<ext assembly="/bin/SSOUtilities" type="SSOUtilities.sso" alias="sso" />
I'm trying to reference a custom class file in XSLT code. I deployed it as a DLL file to the /Bin directory.
Keep getting this error:
System.Xml.Xsl.XslTransformException: Cannot find the script or external object that implements prefix 'urn:sso'.
CS File Declarations:
namespace SSOUtilities
{
public class sso
XSLT Reference:
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:sso="urn:sso"
xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:umbraco.contour="urn:umbraco.contour"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets umbraco.contour sso">
config/xsltExtensions.config declaration:
<ext assembly="/bin/SSOUtilities" type="SSOUtilities.sso" alias="sso" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在 Umbraco 4.5 中,您不再需要将 /bin/ 放入 config/xsltExtensions.config 声明中,因此如果您使用 Umbraco 4.5,这可能会导致错误。
http://our.umbraco.org/ wiki/about/roadmap/umbraco-45/升级到-umbraco-45
In Umbraco 4.5 you no longer need to put the /bin/ in the config/xsltExtensions.config declaration so this may be causing your error if you are using Umbraco 4.5.
http://our.umbraco.org/wiki/about/roadmap/umbraco-45/upgrading-to-umbraco-45
让我添加另一个答案,其中包含我的一个扩展的完整示例。 Embed.cs 类:
它被构建为 Omega.XsltExtensions.dll 并复制到 Umbraco 的 /bin 目录。
在我的 xsltExtensions.config 中,我添加了:
使用此扩展的空 XSLT 文件如下所示:
希望当您将其与此版本进行比较时,您可以发现您的版本中的任何遗漏。
Let me add another answer with a complete example of one of my extensions. The class Embed.cs:
This is being built as Omega.XsltExtensions.dll and copied to Umbraco's /bin directory.
In my xsltExtensions.config I've added:
An empty XSLT file that uses this extension looks like this:
Hopefully you can spot any omissions in your version when you compare it to this one.
您还应该将“sso”添加到您的排除结果前缀中,这应该可以使其工作。
另外,你的类应该继承自ApplicationBase,我不确定静态类是否可以工作:
如果我没有记错的话,那就是使用umbraco.BusinessLogic。
You should add "sso" to your exclude-result-prefixes as well, the should make it work.
Also, your class should inherit from ApplicationBase and I'm not sure if a static class will work:
And that is using umbraco.BusinessLogic if I'm not mistaken.
它最终成为 xsltExtensions.config 中的语法问题,
请注意安装 Contour 时放置在文件中的结束标记。
It ended up being a syntax issue in the xsltExtensions.config
Notice the closing tag which installing Contour placed in the file.