title: Adding a loop to xslt to retrieve images from xml (images located on computer)
body: <p>I'm attempting to add images that correspond to their descriptions</p>
  
  <p>XML code</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!-- Note: For many of the wonders, the experts do not agree on precise dates or construction dimensions.  In these cases, I chose a year or dimension in the middle of the range so all attributes could be numeric. --&gt;
  &lt;ancient_wonders&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Colossus of Rhodes&lt;/name&gt;
          &lt;name language="Greek"&gt;Κολοσσός της Ρόδου&lt;/name&gt;
          &lt;location&gt;Rhodes, Greece&lt;/location&gt;
          &lt;height units="feet"&gt;107&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;282&lt;/year_built&gt;
              &lt;year_destroyed era="BC"&gt;226&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;earthquake&lt;/how_destroyed&gt;
              &lt;story&gt;
          In 294 BC, the people of the island of Rhodes began building a colossal statue of the sun god Helios.  They believed that it was because of his blessings that they were able to withstand a long siege on the island and emerge victorious.&lt;para/&gt;The Colossus was built with bronze, reinforced with iron, and weighted with stones.  While it is often depicted straddling Mandrákion harbor, this is now considered technically impossible; and therefore, it likely stood beside the harbor.&lt;para/&gt;The statue was toppled by an earthquake in 226 BC.  It snapped at the knees and fell over on to the land.  The Oracle of Delphi suggested that it fell because the people of Rhodes had offended Helios, and they decided not to rebuild it.&lt;para/&gt;The statue remained on the ground until 654 AD., and even broken, it was so impressive that many traveled to see it.
        &lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="colossus.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="101" newspaperid="21"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Great Pyramid of Giza&lt;/name&gt;
          &lt;location&gt;Giza, Egypt&lt;/location&gt;
          &lt;height units="feet"&gt;455&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;2570&lt;/year_built&gt;
              &lt;story&gt;
          It is believed to have taken 20 years and as many as 100,000 workers to complete the Great Pyramid, which was built as a tomb for the 4th dynasty Egyptian pharaoh named Khufu.  It was built as part of a complex that included temples and many other pyramids.&lt;para/&gt;The outermost stones of the pyramid were highly polished white limestone, which were eventually loosened by an earthquake more than 600 years ago, and were removed to help build cities and mosques.  When these casing stones were present, some believe that the pyramid was so large and bright that it could be seen from the moon.&lt;para/&gt;There is much speculation about the construction methodologies and intentions of the pyramid, including references to the moon, the Orion constellation, continental gravity, and more.  What is known, however, is that the four sides of the base are more than 700 feet long, and differ in length by no more than 8 inches.  Each side of the pyramid is almost perfectly aligned with the four cardinal points of the compass.  And, the pyramid's dimensions covert to a ratio that equates to 2π with nearly perfect accuracy.
        &lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="pyramid.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="123" newspaperid="71"/&gt;
          &lt;source sectionid="21" newspaperid="42"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Hanging Gardens of Babylon&lt;/name&gt;
          &lt;location&gt;Al Hillah, Iraq&lt;/location&gt;
          &lt;height units="feet"&gt;0&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;600&lt;/year_built&gt;
              &lt;year_destroyed era="BC"&gt;226&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;earthquake&lt;/how_destroyed&gt;
              &lt;story&gt;
          The first and most interesting fact about the gardens is that there is significant controversy about whether the gardens existed at all.&lt;para/&gt;Whether they did or did not exist, there are many elaborate accounts and poetic descriptions of the gardens.  They are generally believed to have been built by King Nebuchadrezzar II for his wife because she missed the gardens of her home.  Some research suggests that it was an elaborate series of rooftop gardens.  Another theory suggests that the gardens were built in the walls of the royal palace.&lt;para/&gt;Babylon, being in the middle of the desert, had no such natural greenery, however; calling into question of how such lushness would have survived in the dryness of the desert.  Recent excavations have suggested the use of an exceptional system of irrigation using a cellar well in conjunction with a chain pump to raise the water to the gardens.  Still, other theories even suggest that the gardens weren't in Babylon at all.  Rather, that they were constructed by Sennacherib at the eastern bank of the Tigris river.&lt;para/&gt;Regardless of the final outcome, it is interesting to note that the imagination of the poets and ancient historians have created one of the Wonders of the World.
        &lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="gardens.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="11" newspaperid="24"/&gt;
          &lt;source sectionid="18" newspaperid="151"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Statue of Zeus at Olympia&lt;/name&gt;
          &lt;name language="Greek"&gt;Δίας μυθολογία&lt;/name&gt;
          &lt;location&gt;Olympia, Greece&lt;/location&gt;
          &lt;height units="feet"&gt;39&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;430&lt;/year_built&gt;
              &lt;year_destroyed era="AD"&gt;426&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;fire&lt;/how_destroyed&gt;
              &lt;story&gt;Carved from ivory, on a throne of cedarwood, the statue was created by the Greek sculptor Phidias around 430 BC.  In its right hand was a life-size statue of Nike, the goddess of victory, and in its left was a large sceptre topped with an eagle.  The statue, nearly 40 feet tall, was said to fill the entire width of the one of the aisles of the Temple of Zeus, and its head nearly scraped the temple's ceiling.&lt;para/&gt;In 426 AD, the temple was destroyed and many historians believe that the statue was destroyed at that time. Others believe, however, that the statue was moved to Constantinople (now Istanbul) and was destroyed about 50 years later.&lt;para/&gt;Although many copies of the statue were made during its 800+ year lifespan, none are known to have survived.&lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="zeus.jpg" w="528" h="349"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Temple of Artemis at Ephesus&lt;/name&gt;
          &lt;name language="Greek"&gt;Ἀρτεμίσιον&lt;/name&gt;
          &lt;location&gt;Ephesus, Turkey&lt;/location&gt;
          &lt;height units="feet"&gt;60&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;550&lt;/year_built&gt;
              &lt;year_destroyed era="BC"&gt;356&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;fire&lt;/how_destroyed&gt;
              &lt;story&gt;The Temple of Artemis at Ephesus was built and rebuilt over the course of many years.  The most famous was built in about 550 BC and was funded by King Croesus of Lydia.&lt;para/&gt;Unlike many other temples of its time, it was built of marble and glittered with gold.  The temple's foundation was over 180 by 350 feet and its steps led to a high platform on which stood more than one hundred beautifully sculptured columns that supported its roof.  At least twice the size of the Parthenon, it was so breathtaking it was said to rise to the clouds.&lt;para/&gt;The temple housed many incredible works of art, but the most famous was the statue of Artemis herself.  Although the original no longer exists, it was thought to have been made of gold and other beautiful materials.  Her legs were covered with animals and bees and the top of the body covered with breasts symbolizing fertility.&lt;para/&gt;Although destroyed and rebuilt many times, and ultimately left to be destroyed by man, nature and neglect, the most famous version of the temple was destroyed by arson committed by a man named Herostratus on the night Alexander the Great was born.&lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="artemis.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="92" newspaperid="19"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Mausoleum at Halicarnassus&lt;/name&gt;
          &lt;name language="Greek"&gt;Μαυσωλεῖον Ἁλικαρνασσεύς&lt;/name&gt;
          &lt;location&gt;Bodrum, Turkey&lt;/location&gt;
          &lt;height units="feet"&gt;135&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;352&lt;/year_built&gt;
              &lt;year_destroyed era="AD"&gt;1404&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;earthquake&lt;/how_destroyed&gt;
              &lt;story&gt;The monument was built as a tomb for Mausolus, a governor in the Persian Empire. Sparing no expense, his widowed wife Artemisia (who was also his sister as was considered customary) commissioned well-known Greek architects and artists to design the tomb and sculptural reliefs for each of the four sides of the building.&lt;para/&gt;The monument was almost square, nearly 14 stories tall, and its base was more than 10,000 square feet. Each side of the tomb had nine massive columns, and the top was a stepped pyramid on which stood by a four-horse marble chariot in which there were images of Mausolus and Artemisia.&lt;para/&gt;The monument stood for nearly 17 centuries and was eventually destroyed by a series of earthquakes. And, like the Lighthouse of Alexandria, the tomb was so famous that Mausolus's name has become the root word for large tombs in many languages (for example, "mausoleo" in Spanish).&lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="mausoleum.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="141" newspaperid="21"/&gt;
          &lt;source sectionid="2" newspaperid="19"/&gt;
      &lt;/wonder&gt;
      &lt;wonder&gt;
          &lt;name language="English"&gt;Lighthouse of Alexandria&lt;/name&gt;
          &lt;name language="Greek"&gt;ὁ Φάρος τῆς Ἀλεξανδρείας&lt;/name&gt;
          &lt;location&gt;Alexandria, Egypt&lt;/location&gt;
          &lt;height units="feet"&gt;384&lt;/height&gt;
          &lt;history&gt;
              &lt;year_built era="BC"&gt;280&lt;/year_built&gt;
              &lt;year_destroyed era="AD"&gt;1323&lt;/year_destroyed&gt;
              &lt;how_destroyed&gt;earthquake&lt;/how_destroyed&gt;
              &lt;story&gt;
          Located on the island of Pharos in the harbor of Alexandria, the lighthouse may be the most famous lighthouse in history.  The lighthouse was very different than modern lighthouses in that it was built in three stages, all sloping inward.  Built of marble blocks with lead mortar; the lowest was square, the next octagonal, and the top cylindrical.  Within the lighthouse was a ramp and "dumbwaiter" that allowed wood to be transported to the fire that burned at night.&lt;para/&gt;Inside the open top of the lighthouse was a large curved mirror that was used to reflect the sunlight during the day and the fire at night.  It is said that mariners could see the light up to 35 miles away.  Legends have it that the light was so bright it could be used to burn enemy ships.&lt;para/&gt;There are many stories about its ultimate demise, however, the most likely cause is believed to be as many as 22 earthquakes between 320 AD and 1323 AD which led to its decommission.&lt;para/&gt;The Lighthouse of Alexandria was so famous in ancient times that the island on which it stood, Pharos, became the root word for lighthouse in many languages (for example, "phare" in French).
        &lt;/story&gt;
          &lt;/history&gt;
          &lt;main_image file="lighthouse.jpg" w="528" h="349"/&gt;
          &lt;source sectionid="112" newspaperid="53"/&gt;
      &lt;/wonder&gt;
  &lt;/ancient_wonders&gt;
  </code></pre>
  
  <p>XSLT code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt;
    &lt;xsl:output method="html"/&gt;
  
    &lt;!-- ** XML2e ** --&gt;
    &lt;!-- to follow the book's example, see this and the sections below --&gt;
    &lt;xsl:template match="/"&gt;
  
      &lt;html&gt;
        &lt;head&gt;
          &lt;title&gt;Wonders of the World&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
          &lt;h1&gt;Seven Wonders of the Ancient World&lt;/h1&gt;
  
          &lt;h2&gt;Overview&lt;/h2&gt;
          &lt;table border="1"&gt;
            &lt;tr&gt;
              &lt;th&gt;Wonder Name&lt;/th&gt;
              &lt;th&gt;Location&lt;/th&gt;
              &lt;th&gt;Height&lt;/th&gt;
            &lt;/tr&gt;
  
  
            &lt;!-- ** XML2e ** --&gt;
            &lt;!-- to follow the book's example, see this and the sections below --&gt;
            &lt;xsl:apply-templates select="ancient_wonders/wonder"&gt;
              &lt;xsl:sort select="height" order="descending" data-type="number" /&gt;
            &lt;/xsl:apply-templates&gt;
          &lt;/table&gt;
          &lt;h2&gt;History&lt;/h2&gt;
          &lt;xsl:apply-templates
      select="ancient_wonders/wonder/history"&gt;
            &lt;xsl:sort select="year_built" order="descending" data-type="number" /&gt;
          &lt;/xsl:apply-templates&gt;
        &lt;/body&gt;
      &lt;/html&gt;
    &lt;/xsl:template&gt;
  
  
    &lt;!-- ** XML2e ** --&gt;
    &lt;!-- to follow the book's example, see this and the sections below --&gt;
    &lt;xsl:template match="wonder"&gt;
      &lt;tr&gt;
        &lt;td&gt;
          &lt;a&gt;
            &lt;xsl:attribute name="href"&gt;
              #&lt;xsl:value-of select="name[@language='English']"/&gt;
            &lt;/xsl:attribute&gt;
            &lt;strong&gt;
              &lt;xsl:value-of select="name[@language='English']"/&gt;
            &lt;/strong&gt;
          &lt;/a&gt;
          &lt;br/&gt;
  
          &lt;!-- ** XML2e ** --&gt;
          &lt;!-- to follow the book's example, see this and the sections below --&gt;
          &lt;xsl:apply-templates select="name[@language!='English']"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
          &lt;xsl:value-of select="location"/&gt;
        &lt;/td&gt;
        &lt;td&gt;
          &lt;xsl:choose&gt;
            &lt;xsl:when test="height != 0"&gt;
              &lt;xsl:value-of select="height"/&gt;
            &lt;/xsl:when&gt;
            &lt;xsl:otherwise&gt;
              unknown
            &lt;/xsl:otherwise&gt;
          &lt;/xsl:choose&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
    &lt;/xsl:template&gt;
  
    &lt;!-- ** XML2e ** --&gt;
    &lt;!-- to follow the book's example, see this section below --&gt;
    &lt;xsl:template match="name[@language!='English']"&gt;
      (&lt;em&gt;
        &lt;xsl:value-of select="."/&gt;
      &lt;/em&gt;)
    &lt;/xsl:template&gt;
    &lt;xsl:template match="history"&gt;
      &lt;a&gt;
        &lt;xsl:attribute name="name"&gt;
          &lt;xsl:value-of
  select="../name[@language='English']"/&gt;
        &lt;/xsl:attribute&gt;
      &lt;/a&gt;
  
  
      &lt;xsl:for-each select="world-wonders/wonder"&gt;
          &lt;img src="main_image" width="200" /&gt;
      &lt;/xsl:for-each&gt;
  
      The &lt;xsl:value-of select="../name[@language='English']"/&gt;
      &lt;xsl:apply-templates select="../name[@language!='English']"/&gt;
      was built in &lt;xsl:value-of select="year_built"/&gt;&lt;xsl:text&gt; 
  &lt;/xsl:text&gt;&lt;xsl:value-of select="year_built/@era"/&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="year_destroyed != 0"&gt;
          and was destroyed by &lt;xsl:value-of select="how_destroyed"/&gt;
          in &lt;xsl:value-of select="year_destroyed"/&gt; &lt;xsl:text&gt; 
  &lt;/xsl:text&gt;&lt;xsl:value-of select="year_destroyed/@era"/&gt;.
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          and is still standing today.
        &lt;/xsl:otherwise&gt;
      &lt;/xsl:choose&gt;
      &lt;br /&gt;&lt;br /&gt;
    &lt;/xsl:template&gt;
  
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>The primary place that I'm trying to have the images loop is...</p>
  
  <p>xslt code</p>
  
  <pre><code> &lt;xsl:for-each select="world-wonders/wonder"&gt;
          &lt;img src="main_image" width="200" /&gt;
      &lt;/xsl:for-each&gt;
  
      The &lt;xsl:value-of select="../name[@language='English']"/&gt;
      &lt;xsl:apply-templates select="../name[@language!='English']"/&gt;
      was built in &lt;xsl:value-of select="year_built"/&gt;&lt;xsl:text&gt; 
  &lt;/xsl:text&gt;&lt;xsl:value-of select="year_built/@era"/&gt;
      &lt;xsl:choose&gt;
        &lt;xsl:when test="year_destroyed != 0"&gt;
          and was destroyed by &lt;xsl:value-of select="how_destroyed"/&gt;
          in &lt;xsl:value-of select="year_destroyed"/&gt; &lt;xsl:text&gt; 
  &lt;/xsl:text&gt;&lt;xsl:value-of select="year_destroyed/@era"/&gt;.
        &lt;/xsl:when&gt;
        &lt;xsl:otherwise&gt;
          and is still standing today.
        &lt;/xsl:otherwise&gt;
  </code></pre>
  
  <p>I basically wanted to try and add the image right about each description, I'm fairly new to xslt, xml.</p>
  
  <p>Also, I'm not sure if this helps but my images aren't urls they are physically on my computer, another question would be, do I have to have these images stored to a particular location or is my markup simply incorrect (I was checking the  noticed most places claimed that this must have a url provided and i'm not sure if this only works with html files or maybe I just dont have the logic of it. </p>
  
  <p>if someone can explain to me what is actually happening with this piece of code</p>
  
  <pre><code>&lt;xsl:for-each select="world-wonders/wonder"&gt;
          &lt;img src="main_image" width="200" /&gt;
      &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>Shouldn't this technically go through each shebang and slap the image on there?</p>