读书人

初学者有关问题.第一个帮解决的给一半

发布时间: 2012-03-03 15:33:03 作者: rapoo

菜鸟问题.第一个帮解决的给一半分.
打开CHOOSE.ASP页面报错说是
msxml3.dll 错误 '80004005 '

样式表没有包含文档元素。样式表可能是空的,或它可能不是一个标准格式的 XML 文档。

/xml/choose.asp,行 18

choose.asp文件

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<body>
<%
'Load the XML
set xml = Server.CreateObject( "Microsoft.XMLDOM ")
xml.async = false
xml.load(Server.MapPath( "xml2.xml "))
'Load the XSL
set xsl = Server.CreateObject( "Microsoft.XMLDOM ")
xsl.async = false
xsl.load(Server.MapPath( "choose.xsl "))
'Transform the file
Response.Write(xml.transformNode(xsl))
%>
</body>
</html>

choose.xsl文件

<?xml version= "1.0 " encoding= "GB2312 "?> <!-- DWXMLSource= "xml2.xml " -->
   <xsl:stylesheet xmlns:xsl= "http://www.w3.org/TR/WD-xsl ">
   <xsl:template match= "/ ">
   <html>
   <body>
     <table border= "2 " bgcolor= "yellow ">
     <tr>
       <th> Title </th>
       <th> Artist </th>
     </tr>
     <xsl:for-each select= "CATALOG/CD ">
     <tr>
       <td> <xsl:value-of select= "TITLE "/> </td>
     <xsl:choose>
       <xsl:when match= ".[ARTIST= 'Bob Dylan '] ">
         <td bgcolor= "#ff0000 ">
         <xsl:value-of select= "ARTIST "/>
         </td>
       </xsl:when>
       <xsl:otherwise>
         <td> <xsl:value-of select= "ARTIST "/> </td>
       </xsl:otherwise>
       </xsl:choose>
   </tr>
     </xsl:for-each>
     </table>
   </body>
   </html>
   </xsl:template>
   </xsl:stylesheet>

xml2.xml文件

<?xml version= "1.0 " encoding= "GB2312 "?>
<CATALOG>


<CD>
  <TITLE> Empire Burlesque </TITLE>
  <ARTIST> Bob Dylan </ARTIST>
  <COUNTRY> USA </COUNTRY>
  <COMPANY> Columbia </COMPANY>
  <PRICE> 10.90 </PRICE>
  <YEAR> 1985 </YEAR>
</CD>
</CATALOG>

请高手高手高高手指点.

[解决办法]
应该是你的XSL中有些特殊字符,复制下面的代码就好了:
<?xml version= "1.0 " encoding= "gb2312 " ?>
<!--DWXMLSource= "xml2.xml "-->
<xsl:stylesheet xmlns:xsl= "http://www.w3.org/TR/WD-xsl ">
<xsl:template match= "/ ">
<html>
<body>
<table border= "2 " bgcolor= "yellow ">
<tr>
<th> Title </th>
<th> Artist </th>
</tr>
<xsl:for-each select= "CATALOG/CD ">
<tr>
<td> <xsl:value-of select= "TITLE "/> </td>
<xsl:choose>
<xsl:when match= ".[ARTIST= 'Bob Dylan '] ">
<td bgcolor= "#ff0000 ">
<xsl:value-of select= "ARTIST "/>
</td>
</xsl:when>
<xsl:otherwise>
<td> <xsl:value-of select= "ARTIST "/> </td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
[解决办法]
up
[解决办法]
<xsl:when match= ".[ARTIST= 'Bob Dylan '] ">
改成
<xsl:when test= "ARTIST[.= 'Bob Dylan '] ">

读书人网 >XML SOAP

热点推荐