title: XML - Putting images into .xsl
body: <p>I have a "blog" made with XML and XLST.</p>
  
  <p>This is the format of the blog:</p>
  
  <pre><code>&lt;post id="1" category="Miscellaneous"&gt;
  &lt;ptitle&gt;MiG-21&lt;/ptitle&gt;
  &lt;psubtitle&gt;Mikoyan-Gurevich MiG-21&lt;/psubtitle&gt; 
  &lt;image&gt;&lt;/image&gt;
  &lt;author&gt; Brian Livori &lt;/author&gt; 
  &lt;date&gt; 11/10/2012 &lt;/date&gt;
  &lt;par&gt; The Mikoyan-Gurevich MiG-21 (Russian: Микоян и Гуревич МиГ-21; NATO reporting name: Fishbed) is a supersonic jet fighter aircraft, designed by the Mikoyan-Gurevich Design Bureau in the Soviet Union. It was popularly nicknamed "balalaika", from the aircraft's planform-view resemblance to the Russian stringed musical instrument or ołówek (English: pencil) by Polish pilots due to the shape of its fuselage.[2]
  
  Early versions are considered second-generation jet fighters, while later versions are considered to be third-generation jet fighters. Some 50 countries over four continents have flown the MiG-21, and it still serves many nations a half-century after its maiden flight. The fighter made aviation records. At least by name, it is the most-produced supersonic jet aircraft in aviation history and the most-produced combat aircraft since the Korean War, and it had the longest production run of a combat aircraft (1959 to 1985 over all variants).
  &lt;/par&gt;
  &lt;source&gt;http://en.wikipedia.org/wiki/Mikoyan-Gurevich_MiG-21&lt;/source&gt;
  &lt;comments&gt;dsgsdg&lt;/comments&gt;
  &lt;/post&gt;
  
  &lt;post id="2" category="Miscellaneous"&gt;
  &lt;ptitle&gt;MiG-21&lt;/ptitle&gt;
  &lt;psubtitle&gt;Mikoyan-Gurevich MiG-21&lt;/psubtitle&gt; 
  &lt;image&gt;&lt;/image&gt;
  &lt;author&gt; Brian Livori &lt;/author&gt; 
  &lt;date&gt; 11/10/2012 &lt;/date&gt;
  &lt;par&gt; The Mikoyan-Gurevich MiG-21 (Russian: Микоян и Гуревич МиГ-21; NATO reporting name: Fishbed) is a supersonic jet fighter aircraft, designed by the Mikoyan-Gurevich Design Bureau in the Soviet Union. It was popularly nicknamed "balalaika", from the aircraft's planform-view resemblance to the Russian stringed musical instrument or ołówek (English: pencil) by Polish pilots due to the shape of its fuselage.[2]
  
  Early versions are considered second-generation jet fighters, while later versions are considered to be third-generation jet fighters. Some 50 countries over four continents have flown the MiG-21, and it still serves many nations a half-century after its maiden flight. The fighter made aviation records. At least by name, it is the most-produced supersonic jet aircraft in aviation history and the most-produced combat aircraft since the Korean War, and it had the longest production run of a combat aircraft (1959 to 1985 over all variants).
  &lt;/par&gt;
  &lt;source&gt;http://en.wikipedia.org/wiki/Mikoyan-Gurevich_MiG-21&lt;/source&gt;
  &lt;comments&gt;dsgsdg&lt;/comments&gt;
  &lt;/post&gt;
  </code></pre>
  
  <p>I would like to insert an image for each blog post.</p>
  
  <p>How can I do this?</p>
  
  <p>This is my .xls file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
  &lt;xsl:output method="html"/&gt;
  
  &lt;xsl:template match ="/"&gt;
  
      &lt;html&gt;
      &lt;body&gt;
          &lt;table align="center" &gt;
              &lt;tr bgcolor="C77838"&gt;
                  &lt;th&gt;Brian's Blog &lt;/th&gt;
                  &lt;th&gt;About&lt;/th&gt;
                  &lt;th&gt;Contact&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
  
          &lt;table align="center"  bgcolor="1D6135"&gt;
  
          &lt;tr align="center"&gt;
  
          &lt;xsl:element name="img" &gt;
            &lt;xsl:attribute name="border"&gt;0&lt;/xsl:attribute&gt;
            &lt;xsl:attribute name="src"&gt;images/banner.jpg&lt;/xsl:attribute&gt;
            &lt;xsl:attribute name="alt"&gt;Banner&lt;/xsl:attribute&gt;
           &lt;/xsl:element&gt;
  
          &lt;/tr&gt;
  
          &lt;tr align="center"&gt;
          &lt;h1&gt;JET FIGHTERS&lt;/h1&gt;
          &lt;/tr&gt;
  
          &lt;/table&gt;
          &lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;
  
          &lt;table &gt;
              &lt;td width="10%" bgcolor="white"&gt;&lt;/td&gt;
  
              &lt;td bgcolor="CC9933"&gt;
              &lt;xsl:for-each select="blog/post"&gt;
              &lt;tr bgcolor="FFFF99" &gt;&lt;td&gt;&lt;xsl:value-of select="ptitle"/&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr bgcolor="FFFFCC"&gt;&lt;td&gt;&lt;xsl:value-of select="psubtitle"/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;
              &lt;tr bgcolor="FFFFCC"&gt;&lt;td&gt;&lt;xsl:value-of select="image"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
              &lt;tr&gt;&lt;td&gt;&lt;xsl:value-of select="par"/&gt;&lt;/td&gt;&lt;/tr&gt;&lt;br&gt;&lt;/br&gt;&lt;br&gt;&lt;/br&gt;
              &lt;tr bgcolor="D6D6B2"&gt;&lt;td&gt;Source: &lt;xsl:value-of select="source"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
              &lt;br&gt;&lt;/br&gt;&lt;tr bgcolor="FFFFCC"&gt;Posted on: &lt;xsl:value-of select="date"/&gt; by &lt;xsl:value-of select="author"/&gt;&lt;/tr&gt;
              &lt;br&gt;&lt;/br&gt;&lt;tr bgcolor="FFFFCD"&gt;Comments: &lt;xsl:value-of select="comments"/&gt; by &lt;xsl:value-of select="comments"/&gt;&lt;/tr&gt;
              &lt;hr color="white"&gt;&lt;/hr&gt;
              &lt;/xsl:for-each&gt;
              &lt;/td&gt;
  
              &lt;td width="10%" bgcolor="white"&gt;&lt;/td&gt;
          &lt;/table&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="list"&gt;
     Images are element contents, apply a template to all image elements:
     &lt;xsl:apply-templates select="image"/&gt;
     Images are attribute values of an element, we do it differently:
     &lt;xsl:apply-templates select="image3"/&gt;
  &lt;/xsl:template&gt;
  
  &lt;xsl:template match="image1"&gt;
                  &lt;p&gt; &lt;img src="{@source}"/&gt;&lt;br/&gt;&lt;xsl:value-of select="."/&gt; &lt;/p&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>