DSO相关

DSO相关

 

内联数据岛

<html>

         <head>

                   <title>DSO</title>

</head>

 

<body>

         <xml  id=”id_name_for_xmldata”>

         </xml>

    … …

</body>

</html>

 

链接XML数据岛

标签链接

<html>

         <head>

                   <title>DSO</title>

</head>

 

<body>

         <xml  id=”id_name_for_xmldata” src=”****.xml”></xml>

         … …

</body>

</html>

 

Javascript链接

<html>

         <head>

                   <title>DSO</title>

                   <script    language=”javascript”>

                            Function load()

                            {

                                     Var xmlDso = id_name.XMLDocument;

         xmlDso.load(“****.xml”);

}

</script>

</head>

 

<body>

         … …

</body>

</html>

 

将数据岛绑定到HTML

Datasrc 按数据岛IDHTML与其关联

                   Datasrc=”#id_name”

 

Datafld HTMXML节点关联

            Datafld=”mode_name”

 

Recordset对象

 

属性                                            

absolutePage      返回记录所在页面                   

absolutePosition      当前记录位子                                 

BOF              当前记录在第一条返回 true            

cacheSize                  返回本地缓存记录数            

EOF              当前记录在最后一条返回 true   

maxRecords       返回最大记录数                

pageCount           记录包含数据页数                

pageSize              指定页面可包含记录数                     

recordCount       返回记录集中记录数           

 

方法

addNew          添加记录

Delete                         删除当前记录

getRows                     读取并存储与数组

move                           移动当前记录位子

moveFirst                            移动到第一条

moveLast                  移动到最后一条

movePrevious           上移

moveNext                  下移

 

EXP

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

<database>

         <school-info>

                   <name>Riverdale 高中</name>

                   <city>纽约</city>

                   <students>550</students>

         </school-info>

         <school-info>

                   <name>Dream Valley 高中</name>

                   <city>布法罗</city>

                   <students>650</students>

         </school-info>

         <school-info>

                   <name>Sutherland 私立学校 </name>

                   <city>波士顿</city>

                   <students>625</students>

         </school-info>

</database>

 

 

<HTML>

    <HEAD>

        <TITLE>使用 XML 数据岛的单记录绑定</TITLE>

   </HEAD>

   <xml id= "schools" src= "example 1.xml"> </xml>

   <BODY>

         <script language ="Javascript">

                   function firstrec()

                   {

                            schools.recordset.moveFirst()

                   }       

                   function nxtrec()

                   {

                            if (!schools.recordset.EOF)

                            {

                                     schools.recordset.moveNext()

                                     if (schools.recordset.EOF)

                                     {

                                               schools.recordset.moveLast()

                                     }

                            }

                   }

                   function prevrec()

                   {                

                            if (!schools.recordset.BOF)

                            {

                               schools.recordset.movePrevious()

                                     if (schools.recordset.BOF)

                                     {

                                               schools.recordset.moveFirst()

                                     }

                            }

                   }

                   function lastrec()

                   {

                            schools.recordset.moveLast()

                   }

         </script>

        <CENTER>

            <H1>

                学校信息

            </H1>                         

            名称: <INPUT TYPE="TEXT" DATASRC="#schools"

                DATAFLD="name" SIZE=25>

                            <br></br>        

            城市: <INPUT TYPE="TEXT" DATASRC="#schools"

                DATAFLD="city" SIZE=25>

                            <br></br>        

            学生人数: <INPUT TYPE="TEXT" DATASRC="#schools"

                DATAFLD="students" SIZE=25>

            <BUTTON ONCLICK="firstrec()" >

                 &lt;&lt;

            </BUTTON>

            <BUTTON ONCLICK="prevrec()" >

                &lt;

            </BUTTON>

            <BUTTON ONCLICK="nxtrec()" >

                &gt;

            </BUTTON>

            <BUTTON ONCLICK="lastrec()">

                &gt;&gt;

            </BUTTON>

        </CENTER>

    </BODY>

</HTML>

 

DSOXSLT切换样式

<html>

<head>

<title> DSO 示例 </title>

<script language = "JavaScript">

function load()

{

                   var xmlDso = sdb.XMLDocument;

                   var xslDso = Stylesheet.XMLDocument;

                  

                   divResults.innerHTML = xmlDso.transformNode(xslDso);

}

</script>

</head>

<body bgcolor= "#FFFFF">

 

<xml id="sdb">

<?xml version= "1.0"?>

<database>

         <school-info>

         <name>Riverdale 高中</name>

         <city>纽约</city>

         <students>550</students>

         </school-info>

         <school-info>

         <name> Dream Valley 高中 </name>

         <city>布法罗</city>

         <students>650</students>

         </school-info>

         <school-info>

                   <name>Sutherland 私立学校 </name>

                   <city>波士顿</city>

                   <students> 625 </students>

         </school-info>

</database>

</xml>

<XML id="Stylesheet">

         <xsl:stylesheet     

        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

         version="1.0">

       <xsl:template match="/database">

<HTML>        

<HEAD>

        <TITLE>切换样式

         </TITLE>

</HEAD>        

<BODY>           

         <xsl:apply-templates select="school-info"/>

</BODY>      

</HTML>

</xsl:template>

  <xsl:template match="school-info">

  <BR></BR>

         <DIV>          

         <font face="Verdana" size="5" color="red">

         <xsl:value-of select="name"/>

         </font>     

         </DIV>

         <DIV>          

         <font face="Verdana" size="4" color="blue">

         <xsl:value-of select="city"/>

         </font>

         </DIV>

         <DIV>          

         <font face="Verdana" size="2" color="green">

         <xsl:value-of select="students"/>

         </font>

         </DIV>

</xsl:template>

</xsl:stylesheet>

</XML>

<DIV ID="divResults"/>

<input type="BUTTON" value="请单击这里" onCLick="load()">

<br>

<hr>

</body>

</html>

posted @ 2008-10-05 13:02  Edward Xie  阅读(230)  评论(0编辑  收藏  举报