我有以下两个输入文件:
groundup.xml:
<?xml version="1.0" ?>
<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>
<head>
<script type="text/javascript" href="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript">
<xsl:text>
function displayHousing(id){
alert(id);
for(var element in $('#housing_navigation').children()){
if(id == element.getAttribute('id')){
$('#' + id + '_content').show().children().show();
}else{
$('#' + id + '_content').hide().children().hide();
}
}
}
displayHousing('</xsl:text><xsl:value-of select="translate(content/root/housing_option_name, ' ', '_')"/><xsl:text>');
</xsl:text>
</script>
</head>
<body>
<div id="housing_navigation">
<xsl:for-each select="content/root">
<span>
<a class="housing_navigation_link">
<!-- set up housing navigation links -->
<xsl:attribute name="id">
<xsl:value-of select="translate(housing_option_name, ' ', '_')"/>
</xsl:attribute>
<xsl:attribute name="href">
<xsl:text>javascript:displayHousing("</xsl:text>
<xsl:value-of select="translate(housing_option_name, ' ', '_')"/>
<xsl:text>");</xsl:text>
</xsl:attribute>
<xsl:value-of select="housing_option_name"/>
</a>
</span>
</xsl:for-each>
</div>
<div id="housing_content">
<xsl:for-each select="content/root">
<div>
<xsl:attribute name="id">
<xsl:value-of select="concat(translate(housing_option_name, ' ', '_'), '_content')"/>
</xsl:attribute>
<h1>
<xsl:value-of select="housing_option_name"/>
</h1>
<h2>
<xsl:value-of select="housing_option_headline"/>
</h2>
</div>
</xsl:for-each>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
这是输出:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" href="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" />
<script type="text/javascript">
function displayHousing(id){
alert(id);
for(var element in $('#housing_navigation').children()){
if(id == element.getAttribute('id')){
$('#' + id + '_content').show().children().show();
}else{
$('#' + id + '_content').hide().children().hide();
}
}
}
displayHousing('The_first_name');
</script>
</head>
<body>
<div id="housing_navigation">
<span>
<a class="housing_navigation_link"
id="The_first_name"
href="javascript:displayHousing("The_first_name");"
>The first name</a>
</span>
<span>
<a class="housing_navigation_link"
id="A_real_housing_option"
href="javascript:displayHousing("A_real_housing_option");"
>A real housing option</a>
</span>
</div>
<div id="housing_content">
<div id="The_first_name_content">
<h1>The first name</h1>
<h2>Live under a desk</h2>
</div>
<div id="A_real_housing_option_content">
<h1>A real housing option</h1>
<h2>where fun comes to multiply</h2>
</div>
</div>
</body>
</html>
现在回答我的两个实际问题:
有没有比Vistual Studio更好的方法来测试这种事情?我得到一个行号和字符,但没有有意义的错误消息。单击前两个链接之一时会显示错误消息。
为什么我在这里收到错误?