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

    >> 关于 XML 的一般性技术讨论,提供 XML入门资料 和 XML教程
    [返回] 中文XML论坛 - 专业的XML技术讨论区XML.ORG.CN讨论区 - XML技术『 XML基础 』 → [求助]这个排序示例为什么不能正常显示? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2687 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: [求助]这个排序示例为什么不能正常显示? 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     cat7h2o 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:5
      积分:71
      门派:XML.ORG.CN
      注册:2004/7/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cat7h2o发送一个短消息 把cat7h2o加入好友 查看cat7h2o的个人资料 搜索cat7h2o在『 XML基础 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cat7h2o的博客楼主
    发贴心情 [求助]这个排序示例为什么不能正常显示?


    这是孟宪会的一个排序示例,可能很多人都见过、用过吧,我的问题是这样的

    我用一下方法保存了Exam.htm以及Style.xsl文件,并保存在同一个路径底下,但当我打开Exam.htm时,出现错误:

    行:18
    字符:4
    错误:缺少对象:'Style.XMLDocument.selectNodes(...)(...)'

    我想可能是环境的原因吧,于是从坛子的“软件下载”中下载安装了“MSXML 4.0 Parser&SDK SP2简体中文版”

    但是,问题依然存在,向各位求救,谢谢!

    源文件:
       把以下两个文件的内容拷贝到本地计算机上,分别保存为相应的文件,在IE5+和XML3.0+的环境下看效果   


    [此贴子已经被作者于2004-7-8 15:09:13编辑过]

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/7/8 14:21:00
     
     cat7h2o 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:5
      积分:71
      门派:XML.ORG.CN
      注册:2004/7/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cat7h2o发送一个短消息 把cat7h2o加入好友 查看cat7h2o的个人资料 搜索cat7h2o在『 XML基础 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cat7h2o的博客2
    发贴心情 Style.xsl代码
    <?xml version="1.0" encoding="gb2312"?>
       <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://lucky.myrice.com" version="1.0">
       <msxsl:script language="VBScript" implements-prefix="user">
       <![CDATA[
       Function getName(node)
       getName = node.Item(0).nodeName
       End Function
       ]]>
       </msxsl:script>
       
       <xsl:template match="/">
       <xsl:apply-templates select="/*"/>
       </xsl:template>
       
       <xsl:template match="/*">
       <table width="100%" border="0" style="font-size:9pt">
       <tr>
       <td align="left"><b>第 <span id="CurrentPage"></span> 页 总 <span id="PageCount"></span> 页    共有 <span id="RecordCount"></span> 条记录</b></td>
       <td align="right"><b>每页记录数:<input onblur="setRecordsPerPage()" id="RecordsPerPage" style="vertical-align:middle;height:15pt;width:30px"/></b></td>
       <td align="right">
       <span id="Paging">
       <input type="button" OnClick="FirstPage()" value="第一页"/>
       <input type="button" OnClick="previousPage(1)" value="上一页"/>
       <input type="button" OnClick="nextPage(1)" value="下一页"/>
       <input type="button" OnClick="LastPage()" value="最末页"/>
       </span>
       </td>
       </tr>
       </table>
       <Table WIDTH="100%" BORDER="0" cellpadding="0" cellspacing="1" style="font-size:11pt" bgcolor="#0099ff">
       <tr bgcolor="#FF6600" style="cursor: hand;padding:5px">
       <xsl:for-each select="./*[1]/*">
       <td align="center">
       <xsl:attribute name="onclick">
       Sort('<xsl:value-of select="user:getName(.)"/>')
       </xsl:attribute>
       <font color="#EEEEEE"><b><u><xsl:value-of select="user:getName(.)"/></u></b></font>
       </td>
       </xsl:for-each>
       </tr>
       <xsl:for-each select="./*[position() < 6 and position() > 0]">
       <xsl:sort select="./*[1]" order="ascending"/>
       <tr bgcolor="#FFCCFF">
       <xsl:for-each select="./*">
       <td> <xsl:value-of select="."/></td>
       </xsl:for-each>
       </tr>
       </xsl:for-each>
       </Table>
       </xsl:template>
       </xsl:stylesheet>
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/7/8 15:03:00
     
     cat7h2o 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:5
      积分:71
      门派:XML.ORG.CN
      注册:2004/7/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cat7h2o发送一个短消息 把cat7h2o加入好友 查看cat7h2o的个人资料 搜索cat7h2o在『 XML基础 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cat7h2o的博客3
    发贴心情 Exam.htm代码
    <HTML>
       <Head>
       <META http-equiv="Content-Type" Content="text/html;charset=gb2312">
       <STYLE>
       body { font-family:宋体; font-size:9pt;}
       th { font-family:宋体; font-size:11pt; font-weight:bold;}
       </STYLE>
       <Script language="vbscript">
       Option Explicit
       
       Dim intRecordsPerPage '每个页面显示的记录数
       intRecordsPerPage = 6 '每个页面显示的记录数,默认设定为6
       
       ' 更新显示页面的函数
       Function window_onload()
       
       ' 显示设定的记录数
       Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " &intRecordsPerPage + 1 & " and position() > 0]"
       transform()
       setPageCount()
       
       End Function
       
       ' 进行XML-XSLT转换,并显示当前记录的一些信息
       Function transform()
       
       DisplayArea.innerHTML = Data.transformNode(Style.DocumentElement)
       RecordsPerPage.Value = intRecordsPerPage
       
       End Function
       
       ' 重新转换XML,并显示一个状态信息
       Function redisplay(intPage)
       
       Dim strDisplay
       Dim intPageCount
       Dim intRecordCount
       
       ' 保存状态信息
       intPageCount = PageCount.innerHTML
       intRecordCount = RecordCount.innerHTML
       transform()
       ' 显示状态信息
       PageCount.innerHTML = intPageCount
       RecordCount.innerHTML = intRecordCount
       CurrentPage.innerHTML = intPage
       
       End Function
       
       ' 重新排序和显示
       Function Sort(strField)
       
       Dim sortField
       Dim sortOrderAttribute
       ' 得到排序属性值
       Set sortField = Style.XMLDocument.selectSingleNode("//xsl:sort/@select")
       Set sortOrderAttribute = Style.XMLDocument.selectSingleNode("//xsl:sort/@order")
       
       ' 改变排序的方式
       If sortField.Value = strField Or sortField.Value = "./*[0]" Then
       If sortOrderAttribute.Value = "descending" Then
       sortOrderAttribute.Value = "ascending"
       Else
       sortOrderAttribute.Value = "descending"
       End If
       Else
       sortField.Value = strField
       sortOrderAttribute.Value = "ascending"
       End If
       
       Set sortField = Nothing
       Set sortOrderAttribute = Nothing
       
       redisplay (CurrentPage.innerHTML)
       
       End Function
       
       ' 重新设置每页的记录数
       Function setRecordsPerPage()
       
       If IsNumeric(RecordsPerPage.Value) Then
       intRecordsPerPage = CInt(RecordsPerPage.Value)
       window_onload
       End If
       
       End Function
       
       ' 显示页数信息
       Function setPageCount()
       
       Dim intTotalRecords
       
       PageCount.innerHTML = getNumberOfPages(intTotalRecords)
       RecordCount.innerHTML = intTotalRecords
       CurrentPage.innerHTML = 1
       
       End Function
       
       ' 计算总页数和总记录数
       Function getNumberOfPages(intTotalRecords)
       
       Dim intPages
       
       intTotalRecords = Data.XMLDocument.selectNodes("/*/*").length
       intPages = intTotalRecords / intRecordsPerPage
       If InStr(intPages, ".") > 0 Then
       intPages = CInt(Left(intPages, InStr(intPages, "."))) + 1
       End If
       
       getNumberOfPages = intPages
       
       End Function
       
       ' "下一页"的处理
       Function nextPage(intPage)
       
       Dim strDisplay
       Dim strDateRange
       
       If CInt(CStr(intPage) * intRecordsPerPage) < Data.selectNodes("/*/*").length Then
       intPage = CInt(intPage) + 1
       Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"
       Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"
       Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"
       redisplay (intPage)
       End If
       
       End Function
       
       ' 处理"上一页"
       Function previousPage(intPage)
       
       Dim strDisplay
       Dim strDateRange
       
       If intPage > 1 Then
       intPage = CInt(intPage) - 1
       Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(" & intPage & ")"
       Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(" & intPage & ")"
       Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() <= " & (CStr(intPage) * intRecordsPerPage) & " and position() > " & (CInt(intPage) - 1) * intRecordsPerPage & "]"
       redisplay (intPage)
       End If
       
       End Function
       
       ' "第一页"的处理
       Function FirstPage()
       
       Style.XMLDocument.selectNodes("//@OnClick")(1).Value = "previousPage(1)"
       Style.XMLDocument.selectNodes("//@OnClick")(2).Value = "nextPage(1)"
       Style.XMLDocument.selectNodes("//xsl:for-each/@select")(1).Value = "./*[position() < " & intRecordsPerPage + 1 & " and position() > 0]"
       transform()
       setPageCount()
       
       End Function
       
       ' "最末页"的处理
       Function LastPage()
       
       Dim intTotalPages
       Dim intTotalRecords
       
       intTotalPages = getNumberOfPages(intTotalRecords)
       nextPage (intTotalPages - 1)
       
       End Function
       </Script>
       </Head>
       <body>
       <p align="center" style="font-weight:bold;font-size:12pt;color:#0000FF;border-bottom:3px double red;padding-bottom:5px">客户关系表</p>
       <XML id='Data'>
       <客户关系表 xmlns:dt="urn:schemas-microsoft-com:datatypes">
       <客户><序号 dt:dt="int">01</序号><姓名>Mi</姓名><电子邮件>water@21cn.com</电子邮件></客户>
       <客户><序号 dt:dt="int">02</序号><姓名>uyi</姓名><电子邮件>Lily@sina.com</电子邮件></客户>
       <客户><序号 dt:dt="int">03</序号><姓名>uiyu</姓名><电子邮件>John@21cn.com</电子邮件></客户>
       <客户><序号 dt:dt="int">04</序号><姓名>Doug</姓名><电子邮件>Karry@163.net</电子邮件></客户>
       <客户><序号 dt:dt="int">05</序号><姓名>Ellen</姓名><电子邮件>vivki@sina.com</电子邮件></客户>
       <客户><序号 dt:dt="int">06</序号><姓名>Frank</姓名><电子邮件>net_lover@mengxianhui.com.cn</电子邮件></客户>
       <客户><序号 dt:dt="int">07</序号><姓名>Greg</姓名><电子邮件>meng@mengxianhui.com</电子邮件></客户>
       <客户><序号 dt:dt="int">08</序号><姓名>Harry</姓名><电子邮件>sunny@xianhui.net</电子邮件></客户>
       <客户><序号 dt:dt="int">09</序号><姓名>Ingrid</姓名><电子邮件>cathy@hotmail.com</电子邮件></客户>
       <客户><序号 dt:dt="int">10</序号><姓名>Jeff</姓名><电子邮件>your@mxh.com</电子邮件></客户>
       <客户><序号 dt:dt="int">11</序号><姓名>Kelly</姓名><电子邮件>Iloveyou@mengxianhui.com</电子邮件></客户>
       <客户><序号 dt:dt="int">12</序号><姓名>Larry</姓名><电子邮件>smilling@mengxianhui.com</电子邮件></客户>
       <客户><序号 dt:dt="int">13</序号><姓名>Mark</姓名><电子邮件>money@21cn.com</电子邮件></客户>
       <客户><序号 dt:dt="int">14</序号><姓名>Nancy</姓名><电子邮件>www@yahoo.com</电子邮件></客户>
       <客户><序号 dt:dt="int">15</序号><姓名>Peter</姓名><电子邮件>dotnet@aol.com</电子邮件></客户>
       <客户><序号 dt:dt="int">16</序号><姓名>Rachel</姓名><电子邮件>billgates@microsoft.com</电子邮件></客户>
       <客户><序号 dt:dt="int">17</序号><姓名>Seth</姓名><电子邮件>flying@yous.net</电子邮件></客户>
       <客户><序号 dt:dt="int">18</序号><姓名>Tim</姓名><电子邮件>agooyboy@lovegirl.com</电子邮件></客户>
       </客户关系表>
       </XML>
       <XML id='Style' src='Style.xsl'></XML>
       <div id="DisplayArea"></div>
       <table border="0" width="100%" style="font-size:11pt;">
       <tr>
       <td align="right">资料来源:【<a href="http://lucky.myrice.com">孟宪会之精彩世界</a>】</td>
       </tr>
       </table>
       </body>
       </HTML>
    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/7/8 15:06:00
     
     cat7h2o 美女呀,离线,快来找我吧!
      
      
      等级:大一新生
      文章:5
      积分:71
      门派:XML.ORG.CN
      注册:2004/7/7

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给cat7h2o发送一个短消息 把cat7h2o加入好友 查看cat7h2o的个人资料 搜索cat7h2o在『 XML基础 』的所有贴子 引用回复这个贴子 回复这个贴子 查看cat7h2o的博客4
    发贴心情 
    手头有个急活
    恳请请斑竹帮帮忙,大侠们不吝赐教!

    谢谢谢谢

    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2004/7/8 15:12:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 XML基础 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2025/9/12 19:33:00

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

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