DSO(可下載執行個體代碼)

來源:互聯網
上載者:User

 

代碼下載

 

文章概要:

  • 相關概念;
  • recordset的使用;
  • 使用XML資料島和XSLT轉換輸出樣式;

一、幾個簡單的概念:

  1. DSO(Data Source Object):XML DSO就是一個Microsoft ActiveX控制項,嵌入到Microsoft Internet Explorer中;
  2. XML資料島:<XML>和 </XML>標籤之間綁定的XML資料稱為XML資料島;

 

     

    二、DSO將所有的記錄儲存在recordset對象中,而recordset對象的屬性和方法可以用於做操作記錄。下面的執行個體感覺起來和DetalsView類似:
    <!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>    <title>無標題頁</title>    <script  type ="text/javascript" >    function previor()    {     if(!mybook.recordset.bof)     {      mybook.recordset.moveprevious();      if(mybook .recordset.bof)      {       mybook.recordset.movefirst();       alert("已經到達第一條記錄");      }     }    }    function next()    {      if(!mybook.recordset.eof)      {         mybook.recordset.movenext();        if(mybook.recordset.eof)        {        mybook.recordset.movelast();        alert ("這是最後一條記錄");        }      }    }    </script></head><body><xml src="books.xml" id="mybook"></xml>    <table  border="1">      <tr>         <td>書名</td>         <td>作者</td>         <td>價格</td>      </tr>      <tr>        <td><div datasrc="#mybook" datafld="title" ></div></td>        <td><div datasrc="#mybook" datafld="authorname"></div></td>        <td>  <div datasrc="#mybook" datafld="price"></div></td>      </tr>     </table><input  type ="button"  value="首條"   onclick ="mybook.recordset.movefirst()"/>     <input  type="button"  value="下一個"  onclick ="next()"/>     <input  type ="button"  value="上一個" onclick ="previor()" />     <input  type ="button"  value="末條"  onclick="mybook.recordset.movelast()" />   </body></html>
    還有和Gridview類似實現:
    <xml src="books.xml" id="mybook"></xml>        <table  datasrc="#mybook" border ="1">     <thead>      <tr>           <td  > 書名</td>           <td  >作者</td>           <td  >價格</td>        </tr>     </thead>               <tr >           <td  ><div datafld="title"></div></td           ><td  ><div datafld="authorname"></div></td>           <td  ><div datafld="price"></div></td>        </tr>     </table>

    三、轉換輸出樣式:

    首先需要兩個XML資料島
        <xml src="books.xml" id="mybook"></xml>    <xml src="XSLTFile.xslt"  id="stylesheet"></xml>

    然後

               var xmlDso = mybook.XMLDocument;            var xslDso = stylesheet.XMLDocument;            divResults.innerHTML = xmlDso.transformNode(xslDso);

    最後輸出:

    哲學 馬克思 100 電腦科學與技術 比爾蓋茨 200 .net 蠟筆小新 150

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.