Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Brinegar 84 posts 162 karma points
    Dec 19, 2013 @ 16:02
    Thomas Brinegar
    0

    Umbraco 7 - XSLT Error Due to Missing Extension

    I've been transferring a lot of our Umbraco 6.1.5 assets into a sandboxed copy of Umbraco 7.  This is a fresh installation of Umbraco 7 but I have a page that makes use of the simple "lowercase" function using the syntax:

    Exslt.ExsltStrings:lowercase(node)

    The exact error I see occuring in the log is:

    Cannot find a script or an extension object associated with namespace 'urn:Exslt.ExsltStrings

    Has anything changed in the latest version of Umbraco?  How can I run a lowercase function in 7?  Is this build missing this extension object?

    Thanks in advance for any assistance!

  • Thomas Brinegar 84 posts 162 karma points
    Dec 19, 2013 @ 17:52
    Thomas Brinegar
    0

    Looking at the stylesheet element I have identified a difference in this version when creating a 'clean' XSLT file:

    Umbraco 7 creates:

    <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:Examine="urn:Examine" exclude-result-prefixes="msxml umbraco.library Examine ">

    Where 6.1.5 created:

    <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" exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 03, 2014 @ 15:19
    Lee Kelleher
    0

    Hi Thomas,

    The EXSLT extension methods have been removed from Umbraco 7 (for various reasons - most of which many of them were broken). I've made a simple package that will bring back the features for Umbraco 7. I hope this helps?

    http://our.umbraco.org//projects/website-utilities/exslt-redux

    Cheers,
    - Lee

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 03, 2014 @ 15:31
    Martin Griffiths
    0

    Hi Lee

    Have you fixed the broken modules or are you only providing the ones that still work?

     

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 03, 2014 @ 15:35
    Lee Kelleher
    0

    Hi Martin,

    For this initial release I've taken a direct copy from the Umbraco 6.2.0 source-code. So it contains the exact same code.

    Moving forwards I may take a look at fixing the issues, but I had tried that previously (whilst it was still in the Umbraco core) and failed to figure it out. (There's some complex things going on with XPathArrayIterators)

    The source-code is up on GitHub if anyone is inclined to have a go :-)

    Cheers,
    - Lee

  • Martin Griffiths 826 posts 1269 karma points c-trib
    Jan 03, 2014 @ 15:37
    Martin Griffiths
    0

    I dont suppose you know offhand, which ones are broken? Or which ones definitely work?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 03, 2014 @ 15:40
    Lee Kelleher
    0

    Yup, I listed them on ticket #U4-2742...

    The ExsltNodeListToXPathNodeIterator method is used by:

    • umbraco.presentation.xslt.Exslt.ExsltMath.highest
    • umbraco.presentation.xslt.Exslt.ExsltMath.lowest
    • umbraco.presentation.xslt.Exslt.ExsltSets.difference
    • umbraco.presentation.xslt.Exslt.ExsltSets.distinct
    • umbraco.presentation.xslt.Exslt.ExsltSets.intersection
    • umbraco.presentation.xslt.Exslt.ExsltSets.leading
    • umbraco.presentation.xslt.Exslt.ExsltSets.trailing

    (The rest of the EXSLT methods work fine)

  • Justin Grimm 56 posts 138 karma points
    Mar 24, 2014 @ 21:13
    Justin Grimm
    0

    Hi Lee,


    Was hoping your package would ressurect the Umbraco Tag xslt extension...but it doesn't appear so. Do you know how I might be able to access it in Umbraco 7?

    Previously I would include it in the xsltExtensions.config file: <ext assembly="umbraco.editorControls" type="umbraco.editorControls.tags.library" alias="tags" />

    And then reference it in my xslt controls.  I'm really in a bind without this.  Thoughts?


    Thanks,
    Justin

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 24, 2014 @ 21:54
    Jan Skovgaard
    1

    Hi Justin

    Hope you don't mind my giving an answer :)

    In Umbraco 7 you need to add XSLT extensions by adding annotations in the assembly containing your xslt extensions.

    Lee has written about it here http://our.umbraco.org/forum/developers/xslt/46533-no-more-xsltExtensionsconfig-in-Umb-7#comment169440 and you can find more information about it on the issue tracker here http://issues.umbraco.org/issue/U4-2742

    If you don't want to add the namespaces to your XSLT files by hand, simply just add your .dll file to the bin folder, and then create a new xslt file. Then the namespaces should be added automatically.

    Hope this helps.

    /Jan

  • Justin Grimm 56 posts 138 karma points
    Mar 24, 2014 @ 22:13
    Justin Grimm
    0

    Hi Jan,

    Appreciate your response. Still a bit confused as to how to include it. For including the dll files, I'm not sure which ones to grab.  Since umbraco.EditorControls.dll is already included in Umbraco 7. And this appears to be what is providing the tags library functions.

    Thanks much,
    Justin

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 24, 2014 @ 22:26
    Lee Kelleher
    1

    Hi Justin,

    As an immediate quick-fix, try this... create a file in your /App_Code folder called TagsLibrary.cs and put the following code in it:

    namespace Our.Umbraco
    {
        [umbraco.XsltExtension("tags")]
        public class TagsLibrary : umbraco.editorControls.tags.library
        {
        }
    }
    

    Now all your old "tags" should work in your XSLTs again.

    What this code is doing is wrapping the old 'tag library' code within a new class and marking that as an XSLT extension. It's a bit hacky, but should work fine.

    Cheers,
    - Lee

  • Justin Grimm 56 posts 138 karma points
    Mar 24, 2014 @ 22:50
    Justin Grimm
    0

    Hi Lee,

    Thanks a lot for the tip. I've got the class file in place. That seems fine. When I try to save my xslt though, it's throwing an error --

    System.Xml.Xsl.XslTransformException: Cannot find a script or an extension object associated with namespace 'urn:tags'.

    Here's how I'm declaring the extension in my xslt

        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:Examine="urn:Examine" xmlns:tags="urn:tags"
        exclude-result-prefixes="msxml umbraco.library Examine tags ">

    Thanks,
    Justin

  • Justin Grimm 56 posts 138 karma points
    Mar 24, 2014 @ 22:53
    Justin Grimm
    0

    Here's my class file.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;

    /// <summary>
    /// Summary description for TagLibrary
    /// </summary>
    ///

    namespace Our.Umbraco
    {
        [umbraco.XsltExtension("tags")]
        public class TagsLibrary : umbraco.editorControls.tags.library
        {
        }
    }

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 24, 2014 @ 23:16
    Lee Kelleher
    0

    @Justin - Just checking, the code file is in the /App_Code folder?

  • Justin Grimm 56 posts 138 karma points
    Mar 25, 2014 @ 15:21
    Justin Grimm
    0

    Yes, /App_code/TagLibrary.cs

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 25, 2014 @ 15:35
    Lee Kelleher
    0

    Ah, it seems to be an issue with XsltExtensions in App_Code not being recognised in v7. (See #U4-3425 for more details)

    So for this to work, you'd need to compile the class into an assembly/DLL and put it in your /bin folder.

  • Justin Grimm 56 posts 138 karma points
    Mar 25, 2014 @ 16:42
    Justin Grimm
    0

    Sorry for the 20 questions I'm a bit of a novice when it comes to custom class libraries, Lee...and thanks again.

    I set a new project/class library in VS2013. I added a reference to umbraco.editorControls. The line "[umbraco.XsltExtension("tags")]" is coming back with an error of it not being an attribute class. Is my syntax off? Code below.

    namespace TagsLibrary
    {
        [umbraco.XsltExtension("tags")]
        public class TagsLibrary : umbraco.editorControls.tags.library
        {
        }

    }

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 25, 2014 @ 16:44
    Lee Kelleher
    0

    Hi Justin, no worries - just wish it was easier to help out.

    For the umbraco.XsltExtension attribute, you'll also need to reference the umbraco.dll (and possibly Umbraco.Core.dll)

  • Justin Grimm 56 posts 138 karma points
    Mar 25, 2014 @ 16:59
    Justin Grimm
    0

    Hi Lee, thanks again for your help and responsiveness. It turned out to by the Umbraco.Core.dll. 

    I was able to compile the class library and dropped the DLL out into my bin folder. Unfortunately, I'm still getting the same xslt error "

    Cannot find a script or an extension object associated with namespace 'urn:tags'

    I tried creating a fresh xslt file thinking the new class would be picked up in the extension declarations, but it wasn't. Is there some other step I'm missing? Here's my final class code:

    namespace TagsLibrary
    {
    [umbraco.XsltExtension("tags")]
    public class TagsLibrary : umbraco.editorControls.tags.library
    {
    }
    }

    Reason for all this trouble is I'm trying to reuse some fairly complex legacy xslt code. Eventually, I'd like to rewrite it in Razor but it's feasible for this one.
    Thanks,
    Justin

  • Justin Grimm 56 posts 138 karma points
    Mar 26, 2014 @ 15:27
    Justin Grimm
    0

    Hi Lee, any other thoughts/options on this one? Or do I need to start rebuilding my macro not using XSLT?

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 26, 2014 @ 16:00
    Lee Kelleher
    0

    Hi Justin, to be honest I'm confused to why it's not working - at the moment I don't have another solution. If the macro isn't too complex, I'd suggest attempting to port it over to Razor. Unless anyone else has a better idea?

  • Justin Grimm 56 posts 138 karma points
    Mar 26, 2014 @ 16:13
    Justin Grimm
    0

    Sadly, it's very complex. I'm going to keep trying to crack how to use the XSLT extensions. Thanks again for your help.

  • Jesper Nielsen 141 posts 498 karma points
    Jan 29, 2015 @ 13:33
    Jesper Nielsen
    1

    Hello,

    Sorry to resurrect an old thread.

    I think the proposed method cannot work, because Xslt requires the methods to be static. So inheriting from the library gives nothing at all. The new class will have no static methods, and only have the inherited instance methods (in this case none)

    So to get it to work, you must not inherit from umbraco.editorControls.tags.library,

    Instead you must declare matching static methods, that in turn will call the static methods on library.

    Just a though. :-)

    I haven't tried it.

    Kind regards,
    Jesper 

Please Sign in or register to post replies

Write your reply to:

Draft