以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (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=43582)


--  作者:owenfan0715
--  发布时间:3/2/2007 10:05:00 PM

--  加上命名空间为什么会报错?
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:para="http://www.xml.com.cn/parameters" elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="parameter" type="ParameterType" abstract="true">
  <xs:annotation>
   <xs:documentation>Comment describing your root element</xs:documentation>
  </xs:annotation>
 </xs:element>
 <xs:complexType name="para:ParameterType" mixed="true"/>
 <xs:complexType name="referenceParameterType">
  <xs:complexContent>
   <xs:extension base="="para:ParameterType"/>
  </xs:complexContent>
 </xs:complexType>
</xs:schema>
这样就会报错,如果去掉那两个para:就不报错!我想加入一个命名空间,如何修改?

--  作者:flyfoxs
--  发布时间:3/6/2007 8:37:00 PM

--  

我猜想你可能是想通过在下面的文档可能是你想要的结果。有两个关键的地方使用了红字标明
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:para="http://www.xml.com.cn/parameters" elementFormDefault="qualified" attributeFormDefault="unqualified" targetNamespace="http://www.xml.com.cn/parameters">

<xs:complexType name="ParameterType" mixed="true">
  <xs:all>
   <xs:element  name="parameter" type="xs:string"/>
  </xs:all>
</xs:complexType>  


  <xs:element name="parameter" type="para:ParameterType" abstract="true">
  <xs:annotation>
   <xs:documentation>Comment describing your root element</xs:documentation>
  </xs:annotation>
</xs:element>

</xs:schema>

name属性可能不能使用Qname,只要在下面的文档中把name元素修改成Qname就会出错就是最好的证据。Qname就是有限定符的名称,通俗点说就是名字中有冒号,不知道我理解的可对。


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:para="http://www.xml.com.cn/parameters" elementFormDefault="qualified" attributeFormDefault="unqualified">

 <xs:complexType name="ParameterType" mixed="true"/>
 <xs:complexType name="referenceParameterType">
  <xs:complexContent>
   <xs:extension base="ParameterType"/>
  </xs:complexContent>
 </xs:complexType>
</xs:schema>


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