我刚学XML,有个SQLSERVER2000下的问题,我搞不清楚

moxiaolu 2003-09-29 03:51:08
我在IIS下建了虚拟目录:northwind,在它下建了template,然后按照SQLSERVER的联机丛书的例子:
<?xml version ='1.0' encoding='UTF-8'?>
<root xmlns:sql='urn:schemas-microsoft-com:xml-sql'
sql:xsl='MyXSL.xsl'>
<sql:query>
SELECT FirstName, LastName FROM Employees FOR XML AUTO
</sql:query>
</root>

将模板 (TemplateWithXSL.xml) 存储在与 template 类型的虚拟名称 (template) 关联的目录中。XSL 文件 (MyXSL.xsl) 也存储在同一目录中。

下面是 XSL 文件:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match = '*'>
<xsl:apply-templates />
</xsl:template>
<xsl:template match = 'Employees'>
<TR>
<TD><xsl:value-of select = '@FirstName' /></TD>
<TD><B><xsl:value-of select = '@LastName' /></B></TD>
</TR>
</xsl:template>
<xsl:template match = '/'>
<HTML>
<HEAD>
<STYLE>th { background-color: #CCCCCC }</STYLE>
</HEAD>
<BODY>
<TABLE border='1' style='width:300;'>
<TR><TH colspan='2'>Employees</TH></TR>
<TR><TH >First name</TH><TH>Last name</TH></TR>
<xsl:apply-templates select = 'root' />
</TABLE>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
下面的 URL 执行模板:
http://IISServer/northwind/template/TemplateWithXSL.xml&contenttype=text/html,可是我得到的是网页错误的信息,而我安装了MSXML3.0后得到的是:
ERROR: 500 Internal Server Error
HResult: 0x80004005
Source: Microsoft XML Extensions to SQL Server
Description: SQLXML:加载 XSL 样式表时出错

IIS下该有的配置,我全都做了,而且我可以通过
http://IISServer/Northwind?template=<ROOT+xmlns:sql="urn:schemas-microsoft-com:xml-sql"><sql:query>select+*+from+Customers+FOR+XML+AUTO</sql:query></ROOT>

得到XML输出- <ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<Customers CustomerID="ALFKI" CompanyName="Alfreds Futterkiste" ContactName="Maria Anders" ContactTitle="Sales Representative" Address="Obere Str. 57" City="Berlin" PostalCode="12209" Country="Germany" Phone="030-0074321" Fax="030-0076545" />
<Customers CustomerID="ANATR" CompanyName="Ana Trujillo Emparedados y helados" ContactName="Ana Trujillo" ContactTitle="Owner" Address="Avda. de la Constitución 2222" City="México D.F." PostalCode="05021" Country="Mexico" Phone="(5) 555-4729" Fax="(5) 555-3745" />
...............................
</ROOT>
我做过很多别的例子,也是一样的不行,这样我就糊涂了,只好来请教各位大虾,我是第一次提问,不好意思,一来就提这么简单的东西
...全文
75 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
leimin 2003-10-01
  • 打赏
  • 举报
回复
我试过你的XML和XLS文件,没有问题。
http://IISServer/northwind/template/TemplateWithXSL.xml?contenttype=text/html
--------------------------- ^^
用问号试试!
moxiaolu 2003-09-30
  • 打赏
  • 举报
回复
我是用SA登陆的,而且你说的那些我都做了,可是就是不行啊,唉,没办法
leimin 2003-09-30
  • 打赏
  • 举报
回复
这应该时你的IIS virtual directory prpertyies的配置有问题,你检查你的security是如何配置的,该用户应该有MSSQLSERVER 指定对象的SELECT ,EXECUTE的权限。

再iis中:
ALLOW URL QUERIES --ENABLE
ALLOW TEMPLATE QUERIES--ENABLE

so you can try:
http://IISServer/northwind/template/TemplateWithXSL.xml?contenttype=text/html
or
http://IISServer/northwind/template/TemplateWithXSL.xml?xsl=MyXSL.xsl
spiketang 2003-09-29
  • 打赏
  • 举报
回复
你都比我们强!
moxiaolu 2003-09-29
  • 打赏
  • 举报
回复
哎,看来是没有人愿意帮我
moxiaolu 2003-09-29
  • 打赏
  • 举报
回复
谢谢各位了
zjcxc 2003-09-29
  • 打赏
  • 举报
回复
up

xml还没学好
aierong 2003-09-29
  • 打赏
  • 举报
回复


xml我也不会
准备国庆去学学
我先顶

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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