如何结合isapi、xml和xsl来做web服务程序

tlovexyj 2001-12-10 11:14:36
加精
用VC做ISAPI,小弟用ODBC API将数据库中提取出的数据根据美工做的模板生成html
可是为了今后的扩展性和可维护性,小弟突发一想,isapi只将数据生成xml写回页面,将其数据和显示(原来是html,用的是CHttpServer)分离,以外部的xsl负责显示,这样在程序dll不必改,只用改xsl即可。
不知可否实现,请诸位大侠提示(详)
...全文
165 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
tlovexyj 2001-12-13
  • 打赏
  • 举报
回复
up~
karma 2001-12-12
  • 打赏
  • 举报
回复
sorry, my email account has been bombarded by sick people with virus-infected emails lately , I do not want to reveal my email account in public
tlovexyj 2001-12-12
  • 打赏
  • 举报
回复
o i am sorry about that~
i just want to ... ... hehe, forget that~
karma 2001-12-11
  • 打赏
  • 举报
回复
if you are developing intranet applications, then normally the client machines are powerful, sending data to the client and processing data there is not a problem

if your xml data is dynamic and you are developing applications for users with diverse machine capabilities, then you have no choice but do the transformation on the server
tlovexyj 2001-12-11
  • 打赏
  • 举报
回复
谢谢无为兄。
我想比较实用一点的就数c和d了。而xsl最好单个xml对应,放在外面。
在c中,server端轻松了(只用做1读数据2生成xml),但是如果数据一大堆,传给client端的html中一大块xml island,不爽而且不安全。
在d中,server端要每个client访问都需要用dom来transformation xml,这样负荷要成倍增长。
tlovexyj 2001-12-11
  • 打赏
  • 举报
回复
2 无为:
i choose 2 for me, 3x for ur answer.
i will try it in my developing application, 3x again~
can u give me ur email? 3x~
karma 2001-12-10
  • 打赏
  • 举报
回复
you can write both XML and XSLT as XML islands and then do transformation in onload event, like this
1.
<xml id="xmldoc">
....
</xml>

<xml id="xsldoc">
....
</xml>
<div id="dv"></div>
<script language="javascript">
function window.onload()
{
document.all("dv").innerHTML = xmldoc.transformNode(xsldoc);
}
</script>

or
2.
<xml id="xmldoc">
....
</xml>

<xml id="xsldoc" src="somexslt.xsl"></xml>
<div id="dv"></div>
<script language="javascript">
function window.onload()
{
document.all("dv").innerHTML = xmldoc.transformNode(xsldoc);
}
</script>
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
我试过了,直接写回xml的数据岛,由于父类是CHttpServer,所以并不能解释并显示出xml
2 无为:
偶知道您是大虾,您说的那个东东俺懂,可是并不是那样就可以的。目前是server应该用哪个,反正CHttpServer是不行的,它对应的是html。而在isapi中,vc的wizard自动建立的就是CHttpServer的一个子类。xml有一个ServerXMLHTTP,我想问的是:结合isapi该如何使用?再有就是xml内容可以直接由类似"select * from 院系基本信息 for xml auto,ELEMENTS"这样的sql语句得到xml数据岛,这样就不用我们自己生成了(如果有特殊需要还是要的)。现在是如何显示的问题。

偶查了查原来的资料,发现还可以这样实现:
<html>
<head>
<script language="JavaScript" for="window" event="onload">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("xmlData/xmlzhgs.asp");

var xslDoc = new ActiveXObject("Microsoft.XMLDOM");
xslDoc.async="false";
xslDoc.load("xslData/zhgs.xsl");

idXML.innerHTML = xmlDoc.transformNode(xslDoc);

function layerShow(strID){
node = xmlDoc.selectSingleNode("//row[@id="+strID+"]");
alert(strID);
while (true){
node = node.nextSibling;
myID = node.getAttribute("id");
if (myID.substr(0,strID.length) == strID){
if (node.getAttribute("show") == "T")
node.setAttribute("show","F");
else
node.setAttribute("show","T");
}
else
break;
}
idXML.innerHTML = xmlDoc.transformNode(xslDoc);
return true;
}
</script>

<title>XML数据库</title>
<LINK rel="stylesheet" type="text/css" href="style5.css">
</head>
<body bgcolor="#FFFFFF">
<div id="idXML"></div>
</body>
</html>

不知道地道否,希望大家一起讨论一下。!!!!!
karma 2001-12-10
  • 打赏
  • 举报
回复
sure, add
<?xml-stylesheet type="text/xsl" href="whatever.xsl" ?> to your XML file, following
<?xml version="1.0" ?>
karma 2001-12-10
  • 打赏
  • 举报
回复
1. "想问问,对比CHttpServer和CHtmlStream,XML有无对应或相关class可代替之? "
you can download MSXML3 SDK or MSXML4 SDK and use classes in them

2. "目前这是否是最地道的解决办法呢"?
these are the normal methods to do XSLT transformation:
a. output xml directly (with an xml-stylesheet pi) and have the browser take care of the transformation
b. embed xml/xsl island inside the pages and do the transformation on the client side using javascript
c. dynamically load xml/xslt and do the transformation on the client side using javascript
d. do the transformation on the server side
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
还有一个想法,就是:
同样实现一个想法,但是所应用的方法"地道"于否,是否应该考虑一下呢?
目前这是否是最地道的解决办法呢?
qick and dirty?
hehe
tlovexyj 2001-12-10
  • 打赏
  • 举报
回复
2 无为:
谢谢,
小弟觉得第2种方法比较好。
俺去试试看。
想问问,对比CHttpServer和CHtmlStream,XML有无对应或相关class可代替之?

8,909

社区成员

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

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