0
我有兩個文件:groundup.xml和groundup.xslt。在xslt中顯示文本時出現問題
groundup.xml:
<content>
<root>
<housing_option_name>The first name</housing_option_name>
<housing_option_headline>Live under a desk</housing_option_headline>
<housing_option_address>Kinda behind the Shell gas station</housing_option_address>
<include_description>true</include_description>
<description_images>/uploadedImages/RecSports/Intramural_Sports/Photos/Basketball 055.jpg</description_images>
<description_images>/uploadedImages/StudyAbroad/Slideshow/Adamwood.jpg</description_images>
<room_types_and_layouts>Here you can sleep. Here you eat.</room_types_and_layouts>
<include_virtual_room_tour>false</include_virtual_room_tour>
<include_photos>true</include_photos>
</root>
<root>
<housing_option_name>A real housing option</housing_option_name>
<housing_option_headline>where fun comes to multiply</housing_option_headline>
<housing_option_address>
The address goes here
</housing_option_address>
<include_description>false</include_description>
<description_images>/uploadedImages/bg_mural_Partner_for_Success.jpg</description_images>
<room_types_and_layouts>Some text about room types and layouts.</room_types_and_layouts>
<include_virtual_room_tour>false</include_virtual_room_tour>
<include_photos>true</include_photos>
</root>
</content>
而且groundup.xslt:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html" indent="yes" encoding="utf-8"/>
<xsl:template match="/">
<html>
<body>
<div id="residence_halls">
<ul>
<xsl:for-each select="content/root">
<div>
<xsl:attribute name="id">
<xsl:value-of select="translate(housing_option_name, ' ', '_')"/>
</xsl:attribute>
<xsl:value-of select="content/root/housing_option_name"/>
</div>
</xsl:for-each>
</ul>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我設法讓housing_option_name到id字段,但是,我還在努力使housing_option_name在最終的html中顯示爲文本。現在,我只是看到一個空白屏幕,但看最後的來源,有兩個div與housing_option_name的id,但沒有文本內的divs。
我在這裏錯過了什麼?
編輯:最終的HTML看起來像這樣:
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<div id="residence_halls">
<div id="The_first_name">
</div>
<div id="A_real_housing_option">
</div>
</div>
</body>
</html>
編輯:掏出ULS爲簡潔
謝謝!我會在九分鐘內讓你接受答案。 :) – lowerkey 2011-02-16 03:35:22