Dynamic values for src in <img src="...."/> in XSL

Discussions

XML & Web services: Dynamic values for src in <img src="...."/> in XSL

  1. Hi,

    How can a .gif file be included in an xsl file using the <img border="0" alt="delete" src="....gif"/>

    when the "src" part is
    1)going to be dynamic and
    2)cannot be returned as a TAG in the XML as well.


    Thanks in advance...
  2. If I understand you correctly, simply do the following:

    <img border="0" alt="delete">
        <xsl:attribute name="src">
           <xsl:value-of select="some-xpath-to-my-filename" />
        </xsl:attribute>
    </img>

    Of course, if you need to doctor the URL (add a path, extension, etc)... you can use the <xsl:text> tag too...

    <img border="0" alt="delete">
        <xsl:attribute name="src">
           <xsl:text>http://some.server.com/with/subfolders/>
           <xsl:value-of select="some-xpath-to-my-filename" />
           <xsl:text>.gif</xsl:text>
        </xsl:attribute>
    </img>


    Hope this helps.

    -Tim.