新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论XSL,XSLT,XSL-FO,CSS等技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XSL/XSLT/XSL-FO/CSS 』 → [求助]XSLT将XML转换为HTML出现错误,请各位帮忙! 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 3584 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [求助]XSLT将XML转换为HTML出现错误,请各位帮忙! 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     dicman 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:79
      门派:XML.ORG.CN
      注册:2005/3/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给dicman发送一个短消息 把dicman加入好友 查看dicman的个人资料 搜索dicman在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看dicman的博客楼主
    发贴心情 [求助]XSLT将XML转换为HTML出现错误,请各位帮忙!

    出现如下错误信息:
    Error Type:
    msxml3.dll (0x80004005)
    The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

    请问是什么原因啊?
    下面是代码:
    XML:
    <?xml version="1.0" encoding="utf-8" ?>
    <?xml-stylesheet type='text/xsl' href='/rss.xsl' version='1.0'?>
    <rss version="2.0">
     <channel>
      <title>MSN Search: site:www.abspc.com AMD</title>
      <link>http://search.msn.com:80/results.aspx?q=site%3awww.abspc.com+AMD</link>
      <description>Search results</description>
      <copyright>Copyright &copy; 2005 Microsoft. All rights reserved. These XML results may not be used, reproduced or transmitted in any manner or for any purpose other than rendering MSN Search results within an RSS aggregator for your personal, non-commercial use. Any other use of these results requires express written permission from Microsoft Corporation. By accessing this web page or using these results in any manner whatsoever, you agree to be bound by the foregoing restrictions.</copyright>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/app/config.asp?mono=1709</link>
       <description> ... Get a Coupon for 4 Months of Napster and 12 Downloads Free from AMD &amp;amp; Napster Operating System More Info Microsoft Windows XP Home with Service Pack 2 (For System Bundle Use ONLY!) - OEM ... </description>
       <pubDate>14 Sep 05 05:34:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/press/press_amd_athlonx2.asp</link>
       <description> ... ABS Joins AMD to Revolutionize the Dual-Core Era WHITTIER, CALIF. -- May 31, 2005 -- ABS, a proud AMD Platinum Solution Provider, is pleased to announce its support for the new AMD Athlon?4 X2 dual ... </description>
       <pubDate>14 Sep 05 04:08:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/diy/Config.asp?Section=201000&amp;amp;CategoryCode=20100004&amp;amp;layout=CB</link>
       <description> ... AMD Athlon XP 2800+ 333MHz FSB Socket A Processor AMD Athlon 64 3200+ 800MHz FSB Socket 754 Processor AMD Athlon 64 3400+ 800MHz FSB Socket 754 Processor Free FedEx Saver Shipping Free FedEx Saver ... </description>
       <pubDate>12 Sep 05 07:24:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/diy/Config.asp?Section=201000&amp;amp;CategoryCode=20100003&amp;amp;layout=CB</link>
       <description> ... Intel BOXD915GAVL ATX Intel Motherboard EPoX EP-9NPA+Ultra ATX AMD Motherboard ABIT Fatal1ty AN8-SLI ATX AMD Motherboard Free FedEx Saver Shipping Free FedEx Saver Shipping Free FedEx Saver Shipping ... </description>
       <pubDate>14 Sep 05 12:01:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/app/config.asp?mono=1711&amp;amp;layout=GZ</link>
       <description> ... AMD/ABS Half Life 2 Promotion More Info AMD Coupon for Half-Life 2 Operating System More Info Microsoft Windows XP Home with Service Pack 2 DVD Version (For System Bundle Use ONLY!) - OEM ... </description>
       <pubDate>19 Sep 05 05:28:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/promo/index.asp</link>
       <description> ... Purchase the processor that takes gaming to the limits. Buy any AMD Athlon™ 64 or AMD Athlon 64 FX processor-based system and get a FREE copy of Half-Life&reg; 2 Bronze offer via Steam™, including ... </description>
       <pubDate>21 Sep 05 07:28:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/ipc/tower.asp</link>
       <description> ... 2GHz Intel Xeon Processors with Hyper-Threading Up to dual AMD Opteron processors 250 Up to Dual AMD Opteron 250 Up to 4GB ECC SDRAM Up to 16GB ... </description>
       <pubDate>17 Sep 05 10:38:00 PST</pubDate>
      </item>
      <item>
       <title>ABS Computer Technologies - Home of the Award winning Ultimate and ... </title>
       <link>http://www.abspc.com/diy/Config.asp?Section=201000&amp;amp;layout=CB</link>
       <description> ... EPoX EP-9NPA+Ultra ATX AMD Motherboard ABIT IS7-V2 ATX Intel Motherboard GIGABYTE GA-7VT600P-RZ ATX AMD Motherboard Free FedEx Saver Shipping Free FedEx Saver Shipping Free FedEx Saver Shipping ... </description>
       <pubDate>12 Sep 05 07:31:00 PST</pubDate>
      </item>
     </channel>
    </rss>

    rss.xsl
    <stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="html" />
     <xsl:param name="top" />
     <xsl:param name="page" />
     <xsl:param name="searchterm" />
     <xsl:template match="/">
      <xsl:for-each select="rss/channel/item">
       <xsl:if test="position() &lt; ($top*($page+1)) + 1 and position() &gt; $page * $top">
        <table border="0" cellspacing="0" cellpadding="0">
         <tr>
          <td>
           <a href="{link}">
            <span>
             <xsl:value-of select="title" />
            </span>
           </a>
          </td>
         </tr>
         <tr>
          <td>
           <span>
            <xsl:value-of select="link" />
           </span>
          </td>
         </tr>
         <tr>
          <td>
           <span>
            <xsl:value-of disable-output-escaping="no" select="translate(substring(description,1,150),'/',' /')" />
           </span>
           <hr />
          </td>
         </tr>
        </table>
       </xsl:if>
       <xsl:if test="position()=last()">
        Found <xsl:value-of select="last()" /> results. Displaying <xsl:value-of select="($page * $top) + 1" /> to <xsl:value-of select="$top*($page+1)" />
        <xsl:if test="$page=0">
         <a href="msn-search.asp?term={$searchterm}&amp;page={$page+1}&amp;results={$top}">Next&gt;&gt;</a>
        </xsl:if>
        <xsl:if test="not($page=0)">
         <xsl:if test="$top*($page+1)&gt;last()">
          <a href="msn-search.asp?term={$searchterm}&amp;page={$page}&amp;prev=t&amp;results={$top}">&lt;&lt;Prev</a>
         </xsl:if>
         <xsl:if test="not($top*($page+1)&gt;last())">
          <a href="msn-search.asp?term={$searchterm}&amp;page={$page}&amp;prev=t&amp;results={$top}">&lt;&lt;Prev</a>
          <xsl:text disable-output-escaping="yes">&amp;&nbsp;</xsl:text>
          <a href="msn-search.asp?term={$searchterm}&amp;page={$page+1}&amp;results={$top}">Next&gt;&gt;</a>
         </xsl:if>
        </xsl:if>
       </xsl:if>
      </xsl:for-each>
    </stylesheet>

    msn-search.asp
    <%
     dim searchURL
     dim searchterm,page,top,resultcount
     dim objSrvHTTP,objXslt,objXsltDoc,objXslProc,objXMLDocument
     
     'Get keyword
     searchURL = "http://search.msn.com/results.aspx?q=site%3awww.abspc.com"
     
     if request.QueryString("term") <> "" then
      searchterm = replace(replace(trim(request.QueryString("term"))," ",","),"+",",")
     else
      searchterm = replace(replace(trim(request.Form("sp-q"))," ",","),"+",",")
     end if
     xx=split(searchterm,",")
     
     for i=0 to ubound(xx)
      if trim(xx(i))<>"" then
       searchURL = searchURL & "+" & trim(xx(i))
      end if
     next
     resultcount = 100
     searchURL = searchURL & "&format=rss&count=" & resultcount & "&first=1"

     'Get number of result item each page
     if request.QueryString("results") <> "" then
      top = request.QueryString("results")
     else
      top = 5
     end if
     
     'Get page number
     if Request.QueryString("page") <> "" then
      if Request.QueryString("prev") = "t" then
       page = cstr(CDbl(request.QueryString("page"))-1)
      else
       page = request.QueryString("page")
      end if
     else
      page = "0"
     end if
     
     'Communicate to server
     set objSrvHTTP = server.CreateObject("MSXML2.ServerXMLHTTP")
     objSrvHTTP.open "get",searchURL,false
     objSrvHTTP.send
     
     while objSrvHTTP.readyState <> 4
      objSrvHTTP.waitForResponse 1000
     wend
     
     set objXslt = Server.CreateObject("Msxml2.XSLTemplate")
     set objXsltDoc = Server.CreateObject("Msxml2.FreeThreadedDOMDocument")
     objXsltDoc.async = false
     objXsltDoc.resolveExternals = false
     objXsltDoc.load Server.MapPath("/rss.xsl")
     
     objXslt.StyleSheet = objXsltDoc
     set objXslProc = objXslt.createProcessor()
     objXslProc.input = objSrvHTTP.responseXML
     objXslProc.addParameter "searchterm",searchterm
     objXslProc.addParameter "page",page
     objXslProc.addParameter "top",top
     objXslProc.transform
     
     Response.ContentType = "text/html"
     Response.Write(objXslProc.output)
     
     set objXslProc = nothing
     set objXsltDoc = nothing
     set objSrvHTTP = nothing
     set objXslt = nothing
    %>


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/9/28 17:05:00
     
     Qr 帅哥哟,离线,有人找我吗?
      
      
      威望:9
      等级:博士二年级(版主)
      文章:4392
      积分:29981
      门派:XML.ORG.CN
      注册:2004/5/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Qr发送一个短消息 把Qr加入好友 查看Qr的个人资料 搜索Qr在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Qr的主页 引用回复这个贴子 回复这个贴子 查看Qr的博客2
    发贴心情 
    哪个searchURL是怎么回事,以及msn-search.asp这个文件是如何调用的?看得偶头都晕了!


    [此贴子已经被作者于2005-9-28 22:49:42编辑过]

    ----------------------------------------------
    没人帮忙,那就靠自己,自己才是最好的老师!本人拒绝回答通过站内短消息提出的问题!

    blog:http://Qr.blogger.org.cn

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/9/28 21:32:00
     
     dicman 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:79
      门派:XML.ORG.CN
      注册:2005/3/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给dicman发送一个短消息 把dicman加入好友 查看dicman的个人资料 搜索dicman在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看dicman的博客3
    发贴心情 
    版主请您帮帮我啊,我实在搞不定了,写了很短的测试代码也一样出这样的错误:
    Error Type:
    msxml3.dll (0x80004005)
    The stylesheet does not contain a document element. The stylesheet may be empty, or it may not be a well-formed XML document.

    searchURL是指ServerXMLHTTP请求的URL,返回一个XML,msn-search是从另外一个页面post过来,会取得关键字request.form("sp-q")的值

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/9/29 8:45:00
     
     Qr 帅哥哟,离线,有人找我吗?
      
      
      威望:9
      等级:博士二年级(版主)
      文章:4392
      积分:29981
      门派:XML.ORG.CN
      注册:2004/5/15

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给Qr发送一个短消息 把Qr加入好友 查看Qr的个人资料 搜索Qr在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Qr的主页 引用回复这个贴子 回复这个贴子 查看Qr的博客4
    发贴心情 
    从这段E文可看出,你的XSL文件写得肯定不正确。据提示,stylesheet应该是xsl:stylesheet,其它没细看。searchURL应该没写好,ASP中QueryString有一大堆,你没写清楚,ASP的URL要写完整,别叫人猜啊!

    ----------------------------------------------
    没人帮忙,那就靠自己,自己才是最好的老师!本人拒绝回答通过站内短消息提出的问题!

    blog:http://Qr.blogger.org.cn

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/9/29 9:23:00
     
     dicman 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:79
      门派:XML.ORG.CN
      注册:2005/3/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给dicman发送一个短消息 把dicman加入好友 查看dicman的个人资料 搜索dicman在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 引用回复这个贴子 回复这个贴子 查看dicman的博客5
    发贴心情 
    谢谢版主,我的问题已经解决了,是因为样式表有个很不容易发现的错误,呵呵
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2005/9/30 15:20:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XSL/XSLT/XSL-FO/CSS 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2026/2/16 20:46:58

    本主题贴数5,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    109.375ms