Copied to clipboard

Flag this post as spam?

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


  • Alex 21 posts 41 karma points
    Aug 20, 2010 @ 17:54
    Alex
    0

    Calling .NET static method from XSLT

    I'm having problems calling a .NET method from an XSLT file. What do I have to do in the XSLT to make sure I can call the method?

    If I have a class that I would normally refer to in .NET as MyClient.MyProject.Helper, with a static method called GetComments that returned a XPathNodeIterator object, should I be able to call the GetComments method just be doing the following?

    <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:Helper="urn:MyClient.MyProject.Helper"

    exclude-result-prefixes="msxml umbraco.library Helper">

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

     

      <xsl:param name="currentPage"/>

     

      <xsl:template match="/">

    <xsl:variable name="comments" select="Helper.GetComments($currentPage/@id)//comment"/>

      </xsl:template>

     

    </xsl:stylesheet>

     

    Currently I'm getting an error - 'Error parsing XSLT file'. If I remove the <xsl:variable  /> tag there is no error.

  • jc 64 posts 101 karma points
    Aug 20, 2010 @ 18:11
    jc
    0

    Have you added your assembly to ~/config/xsltExtensions.config ?

    I think you'll also need a semi-colon in there, like this: Helper:GetComments

  • Sascha Wolter 615 posts 1101 karma points
    Aug 21, 2010 @ 02:34
    Sascha Wolter
    0

    Hi Alex,

    haven't got my code with me at the moment, however there is an excellent series on Xslt extensions with step by step guide in the Umbraco.tv section:

    http://umbraco.org/documentation/videos/for-developers/xslt-extensions/introduction-to-xslt-extensions

    Have a look,
    Sascha

Please Sign in or register to post replies

Write your reply to:

Draft