XML中的DSO(数据岛)具体有什么应用呢??与DOM来说 ,哪个用得更多??

coolhealth 2002-11-13 01:12:55
我看书,书中都有说,不过不知道那个dso(数据岛)具体有什么应用。
...全文
60 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
fsdos 2002-11-15
  • 打赏
  • 举报
回复
如果你使用IE浏览器,数据岛肯定会有用处的。
hax 2002-11-15
  • 打赏
  • 举报
回复
数据岛是ms的专有技术,我认为是过渡阶段的产物,不要用它。
Lostinet 2002-11-14
  • 打赏
  • 举报
回复
数据岛的意义是把XML输出到HTML中。那样在浏览器可以方便地使用服务器上的是数据。(或者是一些预定义数据)。

如果你不想输出
<script>
var items=new Array();
items[0]=new Object();
items[0].Text="aaa\"tt\r\n\'";
items[0].Value="vvvvv";
...
..
.
</script>

因为如果用ASP输出这个还挺烦哦。。。
将会变成:

<script>
var items=new Array();
<%For I=LBound(ServerTexts) To UBound(ServerTexts)%>
items[<%=I-LBound(ServerTexts)%>]=new Object();
items[<%=I-LBound(ServerTexts)%>].Text="<%=EncodeJScript(ServerTexts(I))%>";
items[<%=I-LBound(ServerTexts)%>].Value="<%=EncodeJScript(ServerValues(I))%>";
<%End If%>
</script>


这个呢?

<XML id=xdItems>
<%=ServerXMLDOM.xml%>
</XML>
...
<script>
var items=new Array();
with(xdItems.documentElement.selectNodes("item"))
for(var i=0;i<length;i++)
with(item(i))
{
items[i]=new Object();
items[i].Text=getAttribute("Text");
items[i].Value=getAttribute("Value);
}
</script>

把数据定义和处理数据的脚本分开来,写起来会方便好多的。
而且数据弄成XML,在客户端可以重复使用。
孟子E章 2002-11-13
  • 打赏
  • 举报
回复
例子例子:
<META http=equiv="Content-Type" Content="text/html;charset=gb2312">
<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
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</序号><姓名>net_lover</姓名><电子邮件>mengxianhui@21cn.com</电子邮件></客户>
<客户><序号 dt:dt="int">02</序号><姓名>孟子E章</姓名><电子邮件>Lily@sina.com</电子邮件></客户>
<客户><序号 dt:dt="int">03</序号><姓名>http://lucky.myrice.com</姓名><电子邮件>John@21cn.com</电子邮件></客户>
<客户><序号 dt:dt="int">04</序号><姓名>http://lucky.myrice.com</姓名><电子邮件>Karry@163.net</电子邮件></客户>
<客户><序号 dt:dt="int">05</序号><姓名>http://colorweb.go.163.com</姓名><电子邮件>vivki@sina.com</电子邮件></客户>
<客户><序号 dt:dt="int">06</序号><姓名>Frank</姓名><电子邮件>net_lover@mengxianhui.com.cn</电子邮件></客户>

</客户关系表>
</XML>
<XML id='Style'>
<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>
emu 2002-11-13
  • 打赏
  • 举报
回复
我的理解是在网页中定义xml数据或对象,或者在网页中引用xml文件从而获得xml数据或对象。看看:
http://www.google.com/search?q=xml+%E6%95%B0%E6%8D%AE%E5%B2%9B&ie=UTF-8&oe=UTF-8&hl=zh-CN&lr=
fsdos 2002-11-13
  • 打赏
  • 举报
回复
DOM肯定更有用些,不过通常情况是两者互相配合使用,推荐看看实例中的“内容管理----审批新闻”:

http://xmlnews.39203.com/

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧