views:

73

answers:

4

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" />
+1  A: 

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:

public class sso : ApplicationBase

And that is using umbraco.BusinessLogic if I'm not mistaken.

sebastiaan
Added "sso" to the end. But still the same error.
JGrimm
Without the quotes, I hope? :)
sebastiaan
Hah, ya, without the quotes. Let me try the inherit you mentioned. Thanks for the help!
JGrimm
Removed the static and made it a public class. As for inheriting from ApplicationBase, I'm using an example which I've verified works. It does not inherit from ApplicationBase. Any other thoughts? This one is really stumping me.
JGrimm
+2  A: 

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

Tim Saunders
Good to know, Tim. The version I'm current on is: 4.0.3
JGrimm
+2  A: 

Let me add another answer with a complete example of one of my extensions. The class Embed.cs:

using System.Web;
using umbraco.BusinessLogic;

namespace Omega.XsltExtensions
{
    public class Embed
    {
        public static void LogEmbed(int nodeId)
        {
            Log.Add(LogTypes.Open, new User(0), nodeId, "Embedded pano, referer: " + HttpContext.Current.Request.UrlReferrer);
        }
    }
}

This is being built as Omega.XsltExtensions.dll and copied to Umbraco's /bin directory.

In my xsltExtensions.config I've added:

<ext assembly="/bin/Omega.XsltExtensions" type="Omega.XsltExtensions.Embed" alias="Ext.Embed" />

An empty XSLT file that uses this extension looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#x00A0;">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
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:Ext.Embed="urn:Ext.Embed"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Ext.Embed ">

  <xsl:output method="xml" omit-xml-declaration="yes"/>

  <xsl:param name="currentPage"/>

  <xsl:template match="/">
      <xsl:value-of select="Ext.Embed:LogEmbed($currentPage/@id)"/>
  </xsl:template>

</xsl:stylesheet>

Hopefully you can spot any omissions in your version when you compare it to this one.

sebastiaan
+1  A: 

It ended up being a syntax issue in the xsltExtensions.config

  <ext assembly="/bin/Umbraco.Forms.Core" type="Umbraco.Forms.Library" alias="umbraco.contour">
  <ext assembly="/bin/SSOUtilities" type="SSOUtilities.sso" alias="sso" />
  </ext>

Notice the closing tag which installing Contour placed in the file.

JGrimm