以文本方式查看主题

-  W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWL  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  请帮我找找错误  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=43393)


--  作者:lao_cai
--  发布时间:2/23/2007 12:16:00 PM

--  请帮我找找错误
XML文档如下:
<?xml version="1.0" encoding="gb2312"?>
<products xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://eb.ecjtu.jx.cn/ d:\My Documents\XML\05电子商务XML\作业\4-products-schema1.xsd">
 <product ID="101">
  <name>XML解析器</name>
  <unitPrice>$100</unitPrice>
 </product>
 <product ID="102">
  <name>XML编辑器</name>
  <unitPrice>$50</unitPrice>
 </product>
 <product ID="103">
  <name>XML工具箱</name>
  <unitPrice>$200</unitPrice>
 </product>
 <product ID="104">
  <name>XML技术用户指导手册</name>
  <unitPrice>$300</unitPrice>
 </product>
</products>
schema文档如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  targetNamespace="http://eb.ecjtu.jx.cn/">
 <xs:element name="name">
  <xs:simpleType>
   <xs:restriction base="xs:string"/>    
  </xs:simpleType>
 </xs:element>
 <xs:element name="product">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="name"/>
    <xs:element ref="unitPrice"/>
   </xs:sequence>
   <xs:attribute name="ID" use="required">
    <xs:simpleType>
     <xs:restriction base="xs:string">
      <xs:enumeration value="101"/>
      <xs:enumeration value="102"/>
      <xs:enumeration value="103"/>
      <xs:enumeration value="104"/>
     </xs:restriction>
    </xs:simpleType>
   </xs:attribute>
  </xs:complexType>
 </xs:element>
 <xs:element name="products">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="product" maxOccurs="unbounded"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="unitPrice">
  <xs:simpleType>
   <xs:restriction base="xs:string">
    <xs:enumeration value="$100"/>
    <xs:enumeration value="$200"/>
    <xs:enumeration value="$300"/>
    <xs:enumeration value="$50"/>
   </xs:restriction>
  </xs:simpleType>
 </xs:element>
</xs:schema>
怎么也能不过验证,总说我的product没有定义,可是明明定义了,哪位高手能帮忙解决一下


--  作者:admin
--  发布时间:2/24/2007 12:50:00 AM

--  
定义缺省名称空间就好了:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  targetNamespace="http://eb.ecjtu.jx.cn/" xmlns="http://eb.ecjtu.jx.cn/" >

[此贴子已经被作者于2007-2-25 0:39:53编辑过]

--  作者:lao_cai
--  发布时间:2/25/2007 6:01:00 PM

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