请教XML与模式

okcat 2010-03-02 10:57:38
谁帮我看看啊.可以在自己机子上调试下...........

这是验证代码
<%@page language="vb"%>
<%@import namespace="system.xml"%>
<%@import namespace="system.xml.schema"%>
<script runat="server">
dim xtr as xmltextreader
dim xvr as xmlvalidatingreader

sub page_load(ob as object,ev as eventargs)
try
xtr= new xmltextreader(server.mappath("xml.xml"))
xvr=new xmlvalidatingreader(xtr)
xvr.validationtype=validationtype.schema
addhandler xvr.validationeventhandler,addressof showerror
while xvr.read
end while

catch ex as exception
response.write("error accessing xml file")

finally
xtr.close
xvr.close
end try

end sub


sub showerror(ob as object,ev as validationeventargs)
response.write(" <font color='red'>" & ev.message & " </font> <br>")
response.write("line:" & xtr.linenumber & "position:" & xtr.lineposition)
end sub
</script>
<html>
<body>

</body>
</html>


xmlschema.xdr模式文件内容
<?xml version="1.0"?>
<schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:xml-datatype">
<elementtype name="firstname" content="textonly"/>
<elementtype name="lastname" content="textonly/>
<elementtype name="author content="eltonly">
<element type="firstname"/>
<element type="lastname"/>
</elementtype>
<elementtype name="title" content="textonly" />
<elementtype name="price" content="textonly" dt:type="float"/>
<attributetype name="genre" dt:type="string"/>
<attributetype name="style" dt:type="enumeration" dt:value="paperback hardback"/>
<elementtype name="book" content="eltonly">
<element type="title"/>
<element type="author"/>
<element type="price"/>
</elementtype>
<elementtype name="bookstore" content="eltonly">
<element type="book"/>
</elementtype>
</schema>


XML文件
<?xml version="1.0"?>
<bookstore xmlns="x-schema:xmlschema.xdr">
<book>
<title>i am stuent </title>
<author>
<fristname>j </fristname>
<lastname>smith </lastname>
</author>
<price>25 </price>
</book>
</bookstore>



感觉是关联有问题
模式与XML文件关联后,执行验证,报错:
未能找到元素“x-schema:xmlschema.xdr:bookstore”的架构信息。
line:2position:2未能找到元素“x-schema:xmlschema.xdr:book”的架构信息。
line:3position:5未能找到元素“x-schema:xmlschema.xdr:title”的架构信息。
line:4position:8未能找到元素“x-schema:xmlschema.xdr:author”的架构信息。
line:5position:8未能找到元素“x-schema:xmlschema.xdr:fristname”的架构信息。
line:6position:11未能找到元素“x-schema:xmlschema.xdr:lastname”的架构信息。
line:7position:11未能找到元素“x-schema:xmlschema.xdr:price”的架构信息。
line:9position:8
...全文
71 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
okcat 2010-03-02
  • 打赏
  • 举报
回复
顶一下,帮帮忙,两天没人理了
okcat 2010-03-02
  • 打赏
  • 举报
回复
改了,还是报错

无法为命名空间“x-schema:xmlschema.xdr”加载架构 - 应为架构根。请确保根元素是 ,并且命名空间为“http://www.w3.org/2001/XMLSchema”(对于 XSD 架构)或“urn:schemas-microsoft-com:xml-data”(对于 XDR 架构)。。
okcat 2010-03-02
  • 打赏
  • 举报
回复
改了,还是报错

无法为命名空间“x-schema:xmlschema.xdr”加载架构 - 应为架构根。请确保根元素是 ,并且命名空间为“http://www.w3.org/2001/XMLSchema”(对于 XSD 架构)或“urn:schemas-microsoft-com:xml-data”(对于 XDR 架构)。。
wuyq11 2010-03-02
  • 打赏
  • 举报
回复
okcat 2010-03-02
  • 打赏
  • 举报
回复
upupupupupupup
okcat 2010-03-02
  • 打赏
  • 举报
回复
upupupupupupup

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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