Copied to clipboard

Flag this post as spam?

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


  • Bex 444 posts 555 karma points
    Oct 15, 2010 @ 16:38
    Bex
    0

    XSLT Extensions - What's wrong with this?

    Hello!

    I seem to be completely missing something and I am hoping one of you can help..

    I have created an xslt extension which I have used before and I am referencing in a few of my xslt files and alls working well.

    I have now added a new function to my code that I want to call from xslt and it's not happening properly.

    My function is called "GetTeamName", it accepts an Id and returns a string

    My extension is referenced at the top of my xslt like so: (I know i has a random name.. ignore that)

     xmlns:Domains="urn:Domains" 

     

    I have this in my xslt that is calling the id (which it gets from a custom dropdown datatype)

     <xsl:value-of select="data [@alias = 'Team']"/>

     

    To get the team name I am using the following:

    <xsl:variable name="teamId" select="data [@alias = 'Team']"/>
    <strong>Domains:GetTeamName(@teamId)</strong>

    But all I get on the page is Domains:GetTeamName(@teamId) in bold!

    What am I doing wrong? I can't work out what I'm missing as I have used the domains extension before I've just added a new function!

    Bex

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 15, 2010 @ 16:58
    Jonas Eriksson
    0

    Hi! You'll need xsl:value-of select to use the function:

    <xsl:value-of select="Domains:GetTeamName(@teamId)"/>
  • Bex 444 posts 555 karma points
    Oct 15, 2010 @ 17:01
    Bex
    0

    I have tried that and I was getting an error when I run the page? So thought I was doing it wrong.

    I get the error: "Error parsing XSLT file": does that mean there is a problem with my code or the xslt? and how on earth do I debug it?

    I'm sorry feel as if I'm losing the plot as I've worked with these before with no trouble.. having a mental block I think!

  • Bex 444 posts 555 karma points
    Oct 15, 2010 @ 17:04
    Bex
    0

    OMG the light bulb has just come on! My function is expecting an int, where as it's seeing the team Id as a string! doh!

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 15, 2010 @ 17:10
    Jonas Eriksson
    0

    Friday afternoon and all... :) What I see looks good, can you post the "header" of the xslt?

    Try adding ?umbdebugshowtrace=1 to your url to get more information on what's wrong.

    Or run the Xslt with the xslt visualizer (in Umbraco admin Xslt editor), a great tool.

    Other than that: http://en.wikibooks.org/wiki/Umbraco/Create_xslt_exstension_like_umbraco.Library_in_C

    Regards

    Jonas

  • Jonas Eriksson 930 posts 1825 karma points
    Oct 15, 2010 @ 17:14
    Jonas Eriksson
    0

    Aha you solved it, great!

  • Bex 444 posts 555 karma points
    Oct 15, 2010 @ 17:15
    Bex
    1

    I've got it working. I've switched my function to accept a string and then parsing it to an int there and I am running the function as follows:

      <xsl:value-of select="Domains:GetTeamName(data [@alias = 'Team'])"/> 

    Definitely friday afternoon feeling!

Please Sign in or register to post replies

Write your reply to:

Draft