Copied to clipboard

Flag this post as spam?

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


  • Steve Johnston 6 posts 26 karma points
    Aug 13, 2010 @ 01:49
    Steve Johnston
    0

    Problem using XSLT to set HTML attribute

    I've tried 2 different ways in an XSLT file to specify the src attribute of an img.  Both of them just result in src="".

    What's really strange to me is that the following statement by itself returns the correct value:

    <xsl:value-of select="umbraco.library:Item($currentPage/@id, 'prodImage')" />

    But when I move that same statement inside xsl:attribute, I get no value back for the attribute.

    Option #1:

    <img name="PRODUCT_IMAGE">
       <xsl:attribute name="src">
          <xsl:value-of select="umbraco.library:Item($currentPage/@id, 'prodImage')" />
       </xsl:attribute>
    </img>

    Option #2:

    <img name="PRODUCT_IMAGE" src="{umbraco.library:Item($currentPage/@id, 'prodImage')}" />

    Any ideas?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Aug 13, 2010 @ 10:30
    Ismail Mayat
    0

    Steve,

    Try putting the value into a variable and using that variable as the source to the src attribute see if that makes a difference. Also what version of umbraco you using?

    Regards

    Ismail

  • Steve Johnston 6 posts 26 karma points
    Aug 13, 2010 @ 15:48
    Steve Johnston
    0

    Ismail,

    I already tried using a variable too.  Same results.  I can see the value of the variable by itself, but not when I try to use it as an attribute value.  The only way I've been able to get _anything_ to show up in the attribute is when I use hard-coded text as the attribute value.

    I'm on Windows Server 2008.  I saw the problem in Umbraco 4.5.0, and I upgraded to 4.5.1, but it's still happening.

    Steve

  • Chris Koiak 700 posts 2626 karma points
    Aug 13, 2010 @ 17:43
    Chris Koiak
    0

    I don't think the issue is the src attribute I think it's in your XPATH. Try outputting the required value separately and then put it back in the src attribute

  • Steve Johnston 6 posts 26 karma points
    Aug 14, 2010 @ 17:38
    Steve Johnston
    0

    Chris,

    Yes, I can output <xsl:value-of select="umbraco.library:Item($currentPage/@id, 'prodImage')" /> with no problem.  The only time I have a problem is when I attempt to output the value within xsl:attribute tags.

  • Chris Koiak 700 posts 2626 karma points
    Aug 15, 2010 @ 11:25
    Chris Koiak
    0

    Sounds an odd one. What if you wrap the output in a string() function or a concat? e.g. concat(umbraco.library:Item($currentPage/@id, 'prodImage'),'')

Please Sign in or register to post replies

Write your reply to:

Draft