SCRIPT16389:样式表不包含文档元素。样式表可能是空的,或者它可能不是格式良好的XML文档

时间:2014-05-13 11:17:52

标签: html xml xslt

我试图在Internet Explorer中加载它但是它说有错误并且它不会加载。我使用Jscript代码加载我的XSL和XML文档。

我用这个脚本加载我的文档:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">



<head>
<title>UFC Roster</title>

<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("MSXML2.DOMDocument")
xml.async = false
xml.load("UFCRoster.xml")

// Load the XSL
var xsl = new ActiveXObject("MSXML2.DOMDocument")
xsl.async = false
xsl.load("rdRoster.xsl")

// Transform
document.write(xml.transformNode(xsl))
</script>



</head>
<body>


</body>
</html>

并且它说错误在第23行&#34; document.write(xml.transformNode(xsl))&#34;

但我不太清楚为什么会发生这种错误。这是与之相关的XSL文档。它尚未完成,但它根本没有加载,所以我不能对它进行任何更改。

<?xml version="1.0"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" encoding="UTF-8"/>

<xsl:template match="/">

<html>

<head>

    <title>UFC Roster</title>
    <link href="style1.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
</style>
</head>

<body leftmargin="0" topmargin="0"  border="0">
    <a name="top"></a>
    <table width="100%" cellpadding="0" cellspacing="0" ID="Table1" border="0">
    <tr>
    <td valign="bottom">
    <table cellpadding="0" cellspacing="0" ID="Table2">
    <tr>
    <td>
    <table width="100%" cellpadding="0" cellspacing="0" ID="Table3" border="0">
    <tr height="280px">

    <!-- <td valign="bottom"><img src="" id="" border="0" /></td> -->
    </tr>

    <tr>
    <td class="red" valign="top" width="870px" height="310px">
    <table width="100%" cellpadding="6" cellspacing="0" ID="Table4">
    <tr>

    <td align="center" width="920px" valign="top">
    <table cellpadding="0" cellspacing="0" ID="Table7">
    <tr>
    <td height="75px"></td>
    </tr>
    <tr>
    <td valign="top">
    <table cellpadding="0" cellspacing="0" align="right">
    <tr><td>

    <td valign="top">
    <table cellpadding="0" cellspacing="0" align="right">
    <tr><td>

    <xsl:for-each select="UFCFighters/Division" >
    <xsl:if test="@class='Heavyweight'">

    <table cellpadding="0" cellspacing="10">

    <tr>
    <td><a name="{/name}"></a>
    <img class="picborder2" src="images/{details/name}.jpg" alt="{details/name}" width="100px" height="150px" />
    </td>
    <td width="450px">
    <table>
    <tr>
    <td>
    <table>
    <tr>
    <!--Comment--> <td class="name"><xsl:value-of select="details/name" /></td>
    <td class="rightborder"></td>
    <td valign="bottom">
    <table cellpadding="0" cellspacing="5">
    <tr>
    <td class="label"><b>Rank</b></td>

    <td class="value"><xsl:value-of select="details/rank" /></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>
    </tr>

    <tr>
    <td>
    <table>
    <tr>
    <td class="label" height="20px">From</td>
    <td class="value"><xsl:value-of select="From" /></td>
    <td class="rightmargin"></td>
    <td class="label">Fights Out of</td>
    <td class="value"><xsl:value-of select="Fights_out_of" /></td>
    <!-- <td><a href="villains.html#{enemy}"><img src="images/arrow_red.bmp" border="0" /></a></td> -->
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td class="bio"><xsl:value-of select="bio" /></td>
    <td class="age"><xsl:value-of select="age" /></td>
    <td class="height"><xsl:value-of select="height" /></td>
    <td class="weight"><xsl:value-of select="weight" /></td>
    <td class="college"><xsl:value-of select="college" /></td>
    <td class="degree"><xsl:value-of select="degree" /></td>
    <td class="record"><xsl:value-of select="record" /></td>
    <td class="summary"><xsl:value-of select="summary" /></td>
    <td class="submissions"><xsl:value-of select="submissions" /></td>
    <td class="striking"><xsl:value-of select="striking" /></td>
    <td class="takedowns"><xsl:value-of select="takedowns" /></td>
    </tr>

    </table>
    </td>
    </tr>

    <tr> <!--Check This Section -->
    <td class="border" colspan="2"><br/>
    </td>
    </tr>
    </table>

    </xsl:if>
    </xsl:for-each>
    </td></tr>
    </table> 
    </td>
    </tr>
    </table>
    </td> <!-- To here -->


    <td class="smalltext" width="300px" valign="top">
    <table cellpadding="0" cellspacing="0" ID="Table5">
    <tr>
    <td align="right" valign="top" height="75px"><img src="" /></td>
    </tr>
    <tr>
    <td class="border" height="15px"><br /></td>
    </tr>
    <tr>
    <td height="20px">
    <table cellpadding="0" cellspacing="0">
    <tr>
    <td class="rightmarginsmall"><a class="value" href="index.html">Back</a></td>
    <!-- <td><a href="index.html"><img src="images/arrow_red_back.bmp" border="0" /></a></td> -->
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td class="border" height="15px"><br /></td>
    </tr>
    <tr>
    <td height="20px">
    <table cellpadding="0" cellspacing="0">
    <tr>
    <td class="rightmarginsmall"><a class="value" href="rdRoster.xsl">XSLT</a></td>
    <!-- <td><a href="trvillains.xsl"><img src="images/arrow_red.bmp" border="0" /></a></td> -->
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td class="border" height="916px"><br /></td>
    </tr>
    <tr>
    <td height="20px">
    <table cellpadding="0" cellspacing="0">
    <tr>
    <!-- <td class="rightmarginsmall"><a class="value" href="#top">Top</a></td> -->
    <!-- <td><a href="#top"><img src="" border="0" /></a></td> -->
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </td>

    </tr>
    </table>
    </td>
    </tr>

    </table>

    </td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td>
    <table cellpadding="2" cellspacing="0">
    <tr>
    <td class="blacktext">Created 2014</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </body>

</html>


</xsl:template>

</xsl:stylesheet>

我不确定为什么会产生这个错误以及为什么它不会加载。

1 个答案:

答案 0 :(得分:2)

在行xsl.load("rdRoster.xsl")之后输出xsl.parseError.reason,然后您会看到一条错误消息,告诉您解析失败的原因。