zoukankan      html  css  js  c++  java
  • 使用 xsl 对 xml 文档进行动态排序,分页显示的扩展

    在 http://www.asptoday.com/articles/20000724.htm 有非常好的例子,是关于
      使用 xsl 对 xml 文档进行动态排序,分页显示的。
      主要使用三个文件:
      default.asp 把 xml, xsl 文件串起来
      getxml.asp 对 default 来说相当于 xml
      sample.xsl 主要的格式编排工作在这里做
      ===================================================
      我们可以再进一步拓展这个巨酷的例子:
      1。把 getxml.asp 写好。但我们的真正工作不在 asp 里做。我们用 vb。
       这样一会我们就可以把这个贴子一稿多投到 VB 论坛。
       形如: 
       <%@ Language=VBScript %> 
       
    <SCRIPT LANGUAGE=vbscript RUNAT=Server> 
       Dim oMyTool 
       Dim sXML 
       Set oMyTool 
    = Server.CreateObject("MyPackage.MyComponent"
       sXML 
    = oMyTool.GetData() 
       
       Response.ContentType
    ="text/xml" 
       Response.Write sXML 
       
       set oMyTool 
    = nothing 
       
    </SCRIPT> 

       
      2。 在 VB 中我们使用 SQL 2000 的 for XML 来得到所需的 XML String。 
      
    Public Function GetData() As Variant 
       
       
    Dim oConn As ADODB.Connection 
       
    Dim oCmd As Command 
       
    Dim oRS As ADODB.Recordset 
       
    Dim myStream As ADODB.Stream 
       
    'Dim strConn As String 
       Dim strXML As String 
       
       
    Set oConn = New ADODB.Connection 
       oConn.Open (GetConnectionString) 
       
       
    Set oCmd = New ADODB.Command 
       oCmd.ActiveConnection 
    = oConn 
       
       
    Set myStream = New ADODB.Stream 
       myStream.Open 
       
       oCmd.Properties(
    "Output Stream"= myStream 
       
       oCmd.CommandText 
    = "SELECT EmployeeID, LastName, FirstName, BirthDate, Notes " & _ 
       
    "FROM Employees FOR XML auto" 
       
       oCmd.Execute , , adExecuteStream 
       myStream.Position 
    = 0 
       strXML 
    = myStream.ReadText 
       strXML 
    = "<RET>" & strXML & "</RET>" 
       
       GetData 
    = strXML 
       
       
    Set oCmd = Nothing 
       oConn.Close 
       
    Set oConn = Nothing 
       
      
    End Function 

      =============================
      有两点要注意,一是 sql for xml auto 比较土,我们需要自己加上个 root。
      二是我使用 GetConnectionString 获得 sql conn str 是因为把该 str
      放在了 COM+ Construction string 里。这样一会我们就可以把这个贴子一稿多投到
      COM 论坛和多层结构论坛,还有安全性论坛,当然还有 SQL 论坛。
      
      我们只需要对 sample.xsl 稍作修改就可以显示我们的数据了。
  • 相关阅读:
    CodeForces
    网络流
    poj 2185
    树的分治学习
    数位DP
    URAL 1969. Hong Kong Tram
    hdu 4759 Poker Shuffle
    hdu3712 Detector Placement
    分块思想
    莫比乌斯反演
  • 原文地址:https://www.cnblogs.com/ryb/p/460363.html
Copyright © 2011-2022 走看看