Trouble displaying text in xslt
I have two files: groundup.xml and groundup.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>
And 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>
I managed to get the housing_option_name into the id field, however, I'm still trying to get the housing_option_name to display as text in the final html. Right now I just see a blank screen, but looking at the final source, there are the two divs with ids of housing_option_name, but no text inside the divs.
What am I missing here?
Edit: The final html looks like this:
<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>
开发者_如何学JAVA </div>
</body>
</html>
Edit: Took out uls for brevity
<xsl:value-of select="housing_option_name"/>
Surely? Since you're already in a for-each on the content/root path?
精彩评论