how do i pass an image source over from xml using xslt?

Posted on 2009-04-27
Last Modified: 2013-11-18

i am trying to get an image to display in a table on a html page generated by an xsl dcoument.

i am using this line <img> &lt;img src="untitled.bmp"&gt; </img>
 but it will convert the same over in the generated html page. how do i send over the < and > tags so they are formetted for html?

thanks in advance
Question by:kipl20
    LVL 60

    Accepted Solution

    where do you get the text string from?
    is it like that in the source XML?
    Then you should use the attribute disable-output-escaping="yes" on your xsl:value-of
    Els you should just output it correctly

    Author Comment

    worked perfect thanks

    i used this

    <td><xsl:value-of select="img" disable-output-escaping="yes"/></td>
    LVL 39

    Expert Comment

    If this is your XSLT:

    <xsl:template match="/">   <img> <img src="untitled.bmp"> </img></xsl:template>
    then indeed you will have the behavior you mentioned. Instead, try this:

    <xsl:template match="/">   <img src="untitled.bmp" /> </xsl:template>

    you should not try to make elements out of text in XML/XSLT. Instead, just declare them as elements and you should be fine.
    LVL 60

    Expert Comment

    by:Geert Bormans
    LVL 39

    Expert Comment

    aha, that was quick, Geert! Answered and accepted while I was still typing ;-)

    And I see now that the resolved bugs of EE did not really work with &gt etc. I meant the following (for completeness sake, though the original problem was already solved):

    <!-- wrong -->
    <xsl:template match="/">
      <img> &lt;img src="untitled.bmp"&gt; </img>
    <!-- correct -->
    <xsl:template match="/">
      <img src="untitled.bmp" />

    Open in new window


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now