Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml xslt中的图像显示为x';s_Xml_Xslt - Fatal编程技术网

Xml xslt中的图像显示为x';s

Xml xslt中的图像显示为x';s,xml,xslt,Xml,Xslt,好了,伙计们,我试着显示每个段落的图片,而我得到的只是左上角的一个x。有人能解释一下我做错了什么吗 这是XML <?xml version="1.0"?> <!-- 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 middl

好了,伙计们,我试着显示每个段落的图片,而我得到的只是左上角的一个x。有人能解释一下我做错了什么吗

这是XML

<?xml version="1.0"?>
<!-- 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. -->
<ancient_wonders>
<wonder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Mod2Lab2solution.xsd">
    <name language="English">Colossus of Rhodes</name>
    <name language="Greek">Κολοσσός της Ρόδου</name>
    <location>Rhodes, Greece</location>
    <height units="feet">107</height>
    <history>
        <year_built era="BC">282</year_built>
        <year_destroyed era="BC">226</year_destroyed>
        <how_destroyed>earthquake</how_destroyed>
        <story>
    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.<para/>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.<para/>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.<para/>The statue remained on the ground until 654 AD., and even broken, it was so impressive that many traveled to see it.
  </story>
    </history>
    <main_image file="colossus.jpg" w="528" h="349"/>
    <source sectionid="101" newspaperid="21"/>
</wonder>
<wonder>
    <name language="English">Great Pyramid of Giza</name>
    <location>Giza, Egypt</location>
    <height units="feet">455</height>
    <history>
        <year_built era="BC">2570</year_built>
        <story>
    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.<para/>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.<para/>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.
  </story>
    </history>
    <main_image file="pyramid.jpg" w="528" h="349"/>
    <source sectionid="123" newspaperid="71"/>
    <source sectionid="21" newspaperid="42"/>
</wonder>
<wonder>
    <name language="English">Hanging Gardens of Babylon</name>
    <location>Al Hillah, Iraq</location>
    <height units="feet">0</height>
    <history>
        <year_built era="BC">600</year_built>
        <year_destroyed era="BC">226</year_destroyed>
        <how_destroyed>earthquake</how_destroyed>
        <story>
    The first and most interesting fact about the gardens is that there is significant controversy about whether the gardens existed at all.<para/>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.<para/>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.<para/>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.
  </story>
    </history>
    <main_image file="gardens.jpg" w="528" h="349"/>
    <source sectionid="11" newspaperid="24"/>
    <source sectionid="18" newspaperid="151"/>
</wonder>
<wonder>
    <name language="English">Statue of Zeus at Olympia</name>
    <name language="Greek">Δίας μυθολογία</name>
    <location>Olympia, Greece</location>
    <height units="feet">39</height>
    <history>
        <year_built era="BC">430</year_built>
        <year_destroyed era="AD">426</year_destroyed>
        <how_destroyed>fire</how_destroyed>
        <story>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.<para/>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.<para/>Although many copies of the statue were made during its 800+ year lifespan, none are known to have survived.</story>
    </history>
    <main_image file="zeus.jpg" w="528" h="349"/>
</wonder>
<wonder>
    <name language="English">Temple of Artemis at Ephesus</name>
    <name language="Greek">Ἀρτεμίσιον</name>
    <location>Ephesus, Turkey</location>
    <height units="feet">60</height>
    <history>
        <year_built era="BC">550</year_built>
        <year_destroyed era="BC">356</year_destroyed>
        <how_destroyed>fire</how_destroyed>
        <story>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.<para/>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.<para/>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.<para/>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.</story>
    </history>
    <main_image file="artemis.jpg" w="528" h="349"/>
    <source sectionid="92" newspaperid="19"/>
</wonder>
<wonder>
    <name language="English">Mausoleum at Halicarnassus</name>
    <name language="Greek">Μαυσωλεῖον Ἁλικαρνασσεύς</name>
    <location>Bodrum, Turkey</location>
    <height units="feet">135</height>
    <history>
        <year_built era="BC">352</year_built>
        <year_destroyed era="AD">1404</year_destroyed>
        <how_destroyed>earthquake</how_destroyed>
        <story>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.<para/>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.<para/>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).</story>
    </history>
    <main_image file="mausoleum.jpg" w="528" h="349"/>
    <source sectionid="141" newspaperid="21"/>
    <source sectionid="2" newspaperid="19"/>
</wonder>
<wonder>
    <name language="English">Lighthouse of Alexandria</name>
    <name language="Greek">ὁ Φάρος τῆς Ἀλεξανδρείας</name>
    <location>Alexandria, Egypt</location>
    <height units="feet">384</height>
    <history>
        <year_built era="BC">280</year_built>
        <year_destroyed era="AD">1323</year_destroyed>
        <how_destroyed>earthquake</how_destroyed>
        <story>
    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.<para/>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.<para/>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.<para/>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).
  </story>
    </history>
    <main_image file="lighthouse.jpg" w="528" h="349"/>
    <source sectionid="112" newspaperid="53"/>
</wonder>
</ancient_wonders>


未知的 ( ) 这个 建于 被摧毁了 在里面 今天还站着。


尝试更改此部件:

<image>
  <xsl:attribute name="src">
    <xsl:value-of select="wonder/main_image/@file"/>
The <xsl:value-of select="../name[@language='English']"/>
<xsl:apply-templates select="../name[@language='English']"/>
was built in <xsl:value-of select="year_built"/>
<xsl:text>
        </xsl:text><xsl:value-of select="year=built/@era"/>
  </xsl:attribute>
</image>

这个
建于
致:



然后在
结束标记后添加取出的部分。

当您创建
图像时(或
img
),您的上下文是
历史
。这意味着您只需向上访问一个父级即可访问
主图像
。/main\u图像/@文件

使用一个

HTML输出

<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Wonders of the World</title>
   </head>
   <body>
      <h1>Seven Wonders of the Ancient World</h1>
      <h2>Overview</h2>
      <table border="1">
         <tr>
            <th>Wonder Name</th>
            <th>Location</th>
            <th>Height</th>
         </tr>
         <tr>
            <td><a href="#Great Pyramid of Giza"><strong>Great Pyramid of Giza</strong></a></td>
            <td>Giza, Egypt</td>
            <td>455</td>
         </tr>
         <tr>
            <td><a href="#Lighthouse of Alexandria"><strong>Lighthouse of Alexandria</strong></a><br>(<em>ὁ Φάρος τῆς Ἀλεξανδρείας</em>)
            </td>
            <td>Alexandria, Egypt</td>
            <td>384</td>
         </tr>
         <tr>
            <td><a href="#Mausoleum at Halicarnassus"><strong>Mausoleum at Halicarnassus</strong></a><br>(<em>Μαυσωλεῖον Ἁλικαρνασσεύς</em>)
            </td>
            <td>Bodrum, Turkey</td>
            <td>135</td>
         </tr>
         <tr>
            <td><a href="#Colossus of Rhodes"><strong>Colossus of Rhodes</strong></a><br>(<em>Κολοσσός της Ρόδου</em>)
            </td>
            <td>Rhodes, Greece</td>
            <td>107</td>
         </tr>
         <tr>
            <td><a href="#Temple of Artemis at Ephesus"><strong>Temple of Artemis at Ephesus</strong></a><br>(<em>Ἀρτεμίσιον</em>)
            </td>
            <td>Ephesus, Turkey</td>
            <td>60</td>
         </tr>
         <tr>
            <td><a href="#Statue of Zeus at Olympia"><strong>Statue of Zeus at Olympia</strong></a><br>(<em>Δίας μυθολογία</em>)
            </td>
            <td>Olympia, Greece</td>
            <td>39</td>
         </tr>
         <tr>
            <td><a href="#Hanging Gardens of Babylon"><strong>Hanging Gardens of Babylon</strong></a></td>
            <td>Al Hillah, Iraq</td>
            <td>unknown</td>
         </tr>
      </table>
      <h2>History</h2><a name="Great Pyramid of Giza"></a><img src="pyramid.jpg">The Great Pyramid of Giza was built in 2570 and is still standing today.<br><br><a name="Hanging Gardens of Babylon"></a><img src="gardens.jpg">The Hanging Gardens of Babylon was built in 600 and was destroyed by earthquake in 226 BC.<br><br><a name="Temple of Artemis at Ephesus"></a><img src="artemis.jpg">The Temple of Artemis at Ephesus was built in 550 and was destroyed by fire in 356 BC.<br><br><a name="Statue of Zeus at Olympia"></a><img src="zeus.jpg">The Statue of Zeus at Olympia was built in 430 and was destroyed by fire in 426 AD.<br><br><a name="Mausoleum at Halicarnassus"></a><img src="mausoleum.jpg">The Mausoleum at Halicarnassus was built in 352 and was destroyed by earthquake in 1404 AD.<br><br><a name="Colossus of Rhodes"></a><img src="colossus.jpg">The Colossus of Rhodes was built in 282 and was destroyed by earthquake in 226 BC.<br><br><a name="Lighthouse of Alexandria"></a><img src="lighthouse.jpg">The Lighthouse of Alexandria was built in 280 and was destroyed by earthquake in 1323 AD.<br><br></body>
</html>

世界奇迹
古代世界七大奇迹
概述
奇名
位置
高度
埃及吉萨
455

(ὁ Φάρος τῆς Ἀλεξανδρείας) 埃及亚历山大 384
(Μανσωλε)ῖον Ἁλικαρνασσεύς) 土耳其博德鲁姆 135
(λ∑∑∑∑τηωΔον) 罗德岛,希腊 107
(Ἀρτεμίσιον) 以弗所,土耳其 60
(Δίαςμίθολογία) 希腊奥林匹亚 39 伊拉克希拉 未知的 历史吉萨大金字塔建于2570年,至今仍屹立不倒。

巴比伦空中花园建于600年,在公元前226年被地震摧毁。

以弗所的阿耳特弥斯神庙建于550年,在公元前356年被大火烧毁。

奥林匹亚的宙斯雕像建于430年,被大火烧毁公元426年的大火。哈利卡纳索斯的陵墓建于352年,在公元1404年被地震摧毁。罗德斯巨人建于282年,在公元前226年被地震摧毁。亚历山大灯塔建于280年,在公元1323年被地震摧毁。


您将html标记
img
图像
混合在一起?@kfreeman04208抱歉,它应该是
img
,而不是
图像
。如果这仍然不起作用-例如,您的输出显示
,但图像未渲染,则需要将路径调整到图像的实际位置。好的,我想我不明白。main_image/@文件不是图片所在的位置吗?我还尝试了古老的_wonders/wonder/main_image/@文件。还是没什么。我不知道你把图像文件放在哪里了。XML文档中的路径(按原样复制到HTML结果中)假定它们位于源文档所在的同一目录中。如果它们不存在,则浏览器无法显示它们。这不是XSLT问题。您当前的输出是否确实显示了
?好的,我假设由于某种原因visual studio无法检索图像。我是否需要将图像作为资源添加到中?或者,它们可能只是在文件所在的文件夹中?
<img>
  <xsl:attribute name="src">
    <xsl:value-of select="../main_image/@file"/>
  </xsl:attribute>
</img>
<img src="{../main_image/@file}"/>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:strip-space elements="*"/>

    <xsl:template match="/">        
        <html>
            <head>
                <title>Wonders of the World</title>
            </head>
            <body>
                <h1>Seven Wonders of the Ancient World</h1>
                <h2>Overview</h2>
                <table border="1">
                    <tr>
                        <th>Wonder Name</th>
                        <th>Location</th>
                        <th>Height</th>
                    </tr>
                    <xsl:apply-templates select="/ancient_wonders/wonder">
                        <xsl:sort select="height" order="descending" data-type="number" />
                    </xsl:apply-templates>
                </table>
                <h2>History</h2>
                <xsl:apply-templates select="ancient_wonders/wonder/history">
                    <xsl:sort select="year_built" order="descending" data-type="number" />
                </xsl:apply-templates>
            </body>
        </html>
    </xsl:template>

    <xsl:template match="wonder">
        <tr>
            <td>
                <xsl:apply-templates select="name"/>
            </td>
            <td>
                <xsl:apply-templates select="location"/>
            </td>
            <td>
                <xsl:apply-templates select="height"/>
            </td>
        </tr>
    </xsl:template>

    <xsl:template match="height[.=0]">
        <xsl:text>unknown</xsl:text>
    </xsl:template>

    <xsl:template match="name[@language!='English']">
        <br/>
        <xsl:text>(</xsl:text>
        <em><xsl:value-of select="."/></em>
        <xsl:text>)</xsl:text>
    </xsl:template>

    <xsl:template match="name">
        <a href="#{.}">
            <strong>
                <xsl:value-of select="."/>
            </strong>
        </a>
    </xsl:template>

    <xsl:template match="history">
        <a name="{../name[@language='English']}"/>
        <img src="{../main_image/@file}"/>
        <xsl:text>The </xsl:text>
        <xsl:value-of select="../name[@language='English']"/>
        <xsl:text> was built in </xsl:text>
        <xsl:value-of select="year_built"/>
        <xsl:choose>
            <xsl:when test="year_destroyed !=0">
                <xsl:text> and was destroyed by </xsl:text>
                <xsl:value-of select="how_destroyed"/>
                <xsl:text> in </xsl:text>
                <xsl:value-of select="year_destroyed"/> 
                <xsl:text> </xsl:text>
                <xsl:value-of select="year_destroyed/@era"/>
                <xsl:text>.</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text> and is still standing today.</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
        <br /><br />
    </xsl:template>

</xsl:stylesheet>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Wonders of the World</title>
   </head>
   <body>
      <h1>Seven Wonders of the Ancient World</h1>
      <h2>Overview</h2>
      <table border="1">
         <tr>
            <th>Wonder Name</th>
            <th>Location</th>
            <th>Height</th>
         </tr>
         <tr>
            <td><a href="#Great Pyramid of Giza"><strong>Great Pyramid of Giza</strong></a></td>
            <td>Giza, Egypt</td>
            <td>455</td>
         </tr>
         <tr>
            <td><a href="#Lighthouse of Alexandria"><strong>Lighthouse of Alexandria</strong></a><br>(<em>ὁ Φάρος τῆς Ἀλεξανδρείας</em>)
            </td>
            <td>Alexandria, Egypt</td>
            <td>384</td>
         </tr>
         <tr>
            <td><a href="#Mausoleum at Halicarnassus"><strong>Mausoleum at Halicarnassus</strong></a><br>(<em>Μαυσωλεῖον Ἁλικαρνασσεύς</em>)
            </td>
            <td>Bodrum, Turkey</td>
            <td>135</td>
         </tr>
         <tr>
            <td><a href="#Colossus of Rhodes"><strong>Colossus of Rhodes</strong></a><br>(<em>Κολοσσός της Ρόδου</em>)
            </td>
            <td>Rhodes, Greece</td>
            <td>107</td>
         </tr>
         <tr>
            <td><a href="#Temple of Artemis at Ephesus"><strong>Temple of Artemis at Ephesus</strong></a><br>(<em>Ἀρτεμίσιον</em>)
            </td>
            <td>Ephesus, Turkey</td>
            <td>60</td>
         </tr>
         <tr>
            <td><a href="#Statue of Zeus at Olympia"><strong>Statue of Zeus at Olympia</strong></a><br>(<em>Δίας μυθολογία</em>)
            </td>
            <td>Olympia, Greece</td>
            <td>39</td>
         </tr>
         <tr>
            <td><a href="#Hanging Gardens of Babylon"><strong>Hanging Gardens of Babylon</strong></a></td>
            <td>Al Hillah, Iraq</td>
            <td>unknown</td>
         </tr>
      </table>
      <h2>History</h2><a name="Great Pyramid of Giza"></a><img src="pyramid.jpg">The Great Pyramid of Giza was built in 2570 and is still standing today.<br><br><a name="Hanging Gardens of Babylon"></a><img src="gardens.jpg">The Hanging Gardens of Babylon was built in 600 and was destroyed by earthquake in 226 BC.<br><br><a name="Temple of Artemis at Ephesus"></a><img src="artemis.jpg">The Temple of Artemis at Ephesus was built in 550 and was destroyed by fire in 356 BC.<br><br><a name="Statue of Zeus at Olympia"></a><img src="zeus.jpg">The Statue of Zeus at Olympia was built in 430 and was destroyed by fire in 426 AD.<br><br><a name="Mausoleum at Halicarnassus"></a><img src="mausoleum.jpg">The Mausoleum at Halicarnassus was built in 352 and was destroyed by earthquake in 1404 AD.<br><br><a name="Colossus of Rhodes"></a><img src="colossus.jpg">The Colossus of Rhodes was built in 282 and was destroyed by earthquake in 226 BC.<br><br><a name="Lighthouse of Alexandria"></a><img src="lighthouse.jpg">The Lighthouse of Alexandria was built in 280 and was destroyed by earthquake in 1323 AD.<br><br></body>
</html>