Copied to clipboard

Flag this post as spam?

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


  • Jim Lesinski 32 posts 54 karma points
    Mar 31, 2011 @ 19:31
    Jim Lesinski
    0

    How to - Centralized XSLT Library with Custom Functions?

    Hi,

    I am using some C# methods in some of my XSLT files more than once. Now I am wondering if there is a way I can include all my custom C# methods maybe XSLT templates in a single XSLT file or maybe some other way, so I can reference them from a central location. 

    I am sure this is possible and I am hoping someone can point me in the right direction or to some documentation. I did some searches but haven't found it yet. 

    Thanks,
    Jim

  • Ernst Utvik 123 posts 235 karma points
    Mar 31, 2011 @ 20:04
    Ernst Utvik
    1

    You can make a xslt-extension.

    http://en.wikibooks.org/wiki/Umbraco/Create_xslt_exstension_like_umbraco.Library_in_C

    Put your methods in a class using visual studio and put the .dll in bin folder. Register extension in xsltExtensions.xml and umbraco will include xmlns in your new .xslt's. In your old .xslt scripts you have to add xmlns yourself. See link for a more detailed walkthrough :)

  • Jim Lesinski 32 posts 54 karma points
    Mar 31, 2011 @ 21:57
    Jim Lesinski
    0

    Excellent! This is exactly what I was looking for. 

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 31, 2011 @ 22:00
    Tom Fulton
    1

    Hi,

    Also, if you are using 4.6+ you can declare XSLT Extensions just by adding an attribute to your class, and you don't need to add it to the config file.  See:  http://www.nibble.be/?p=95

    -Tom

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Mar 31, 2011 @ 22:19
    Chriztian Steinmeier
    0

    Hi Jim,

    Since you mentioned XSLT templates I'll mention that its possible to include or import stylesheets, which is also great tool for not having duplicate templates lying around.

    /Chriztian 

  • Jim Lesinski 32 posts 54 karma points
    Apr 01, 2011 @ 18:45
    Jim Lesinski
    0

    Thanks guys! 

Please Sign in or register to post replies

Write your reply to:

Draft