Copied to clipboard

Flag this post as spam?

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


  • Lee 1130 posts 3088 karma points
    Jul 20, 2009 @ 15:07
    Lee
    0

    Using XSLT In Image Tag?

    I haven't been able to get my head round why this won't work?

    <img src='<xsl:value-of select="$post/@BlogThumbnail"/>' alt='<xsl:value-of select="$post/@nodeName"/>' />

    I just get this error?

    System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. Line 108, position 12.
    

    Can you please point me in the right direction :)

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 15:08
    Ron Brouwer
    0

    use <img src='>{$post/@BlogThumbnail}"/

    Ron

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 15:09
    Ron Brouwer
    0

    Sorry for markup >>  src="{$post/@BlogThumbnail}"

  • Ron Brouwer 273 posts 768 karma points
    Jul 20, 2009 @ 15:11
    Ron Brouwer
    101

    Finally == <img src="{$post/@BlogThumbnail}" alt="{$post/@nodeName}" />

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jul 20, 2009 @ 15:29
    Douglas Robar
    3

    Ron's right, you want to use the {} syntax to expand the item in place. It is, effectively, a value-of select statement that you can use when you're already inside the value of a tag. You'll see this syntax all the time with the niceUrl(@id) inside an href tag.

    Alternatively, you can use the more verbose but possibly clearer xsl:attribute syntax. It would look like this:

    <img>
        <xsl:attribute name="src"><xsl:value-of select="$post/@BlogThumbnail"/></xsl:attribute>
        <xsl:attribute name="alt"><xsl:value-of select="$post/@nodeName"/></xsl:attribute>
    </img>



    cheers,
    doug.

  • Lee 1130 posts 3088 karma points
    Jul 20, 2009 @ 17:37
    Lee
    0

    Awesome thanks chaps :) ...

    Almost built the first fully Umbraco powered site!  So getting there slowly...

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies