关于xml schame出现的命名空间错误

来源:互联网 发布:图片做视频的软件 编辑:程序博客网 时间:2024/05/17 10:43
rc-resolve.4.2: Error resolving component 'usertype'. It was detected that 'usertype' is in 
 namespace 'http://www.w3.org/2001/XMLSchema', but components from this namespace are not 

 referenceable from schema document 

以上错误来源一以下的关系型xml schame

<?xml version="1.0" encoding="UTF-8"?><!-- 本空间用的是xs --><schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/user3" xmlns:tns="http://www.example.org/user3" elementFormDefault="qualified">      <element name="users" type="tns:userstype"></element><element name="user" type="usertype"></element><element name="name"></element><element name="password"></element><element name="age"></element><complexType name="userstype">  <sequence>   <element  ref="user"></element>  </sequence></complexType><complexType name="usertype">  <sequence>   <element  ref="name"></element>   <element  ref="password"></element>   <element  ref="age"></element>  </sequence>  <attribute  name="id" use="required" > </attribute>  <attribute  name="note" use="optional"  > </attribute></complexType></schema>
为什么呢, 原来是原本的 element  来源于默认的命名空间 
http://www.w3.org/2001/XMLSchema

而对于usertype ,password,age, name 是自定义的命名空间

xmlns:tns="http://www.example.org/user3"
所以必须定义自己命名空间

在ref、、还有就是type中要改

tns:password 之类的



以下就是正确的

0 0
原创粉丝点击