以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  schema 对 xml文件validate的问题 -- 新手提问  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=50951)


--  作者:chengdihan
--  发布时间:8/4/2007 10:20:00 AM

--  schema 对 xml文件validate的问题 -- 新手提问
xml 如下:

<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="note.xsd">

<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

xml schema 如下:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
    <xs:complexType>
      <xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
</xs:element></xs:schema>


我把xml保存为note.xml,xml schema保存为note.xsd。note.xml和note.xsd在同一个文件夹下。但是这个xml schema没有对xml instance起validate的作用。因为无论我怎么改动xml schema,总能打开note.xml并且得到正确的显示。

谢谢高手帮忙指出问题。



--  作者:chengdihan
--  发布时间:8/4/2007 10:54:00 AM

--  
找到答案了。各位高人不必费心了。

http://bbs.xml.org.cn/dispbbs.asp?boardID=23&ID=24785


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms