以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  [求助]在Schema中如何声明既带属性的元素啊  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=51372)


--  作者:guoxhvip
--  发布时间:8/14/2007 6:23:00 PM

--  [求助]在Schema中如何声明既带属性的元素啊
其实题目说得不是很完全
小弟的意思是比方:
<school>
   <class id="1">M</class>
</school>
这样的结构,在dtd中很好办,可是由于初学Schema确实不知道
在Schema里该怎么写
请哪位大侠帮助一下
--  作者:guoxhvip
--  发布时间:8/14/2007 8:05:00 PM

--  
没人理啊?
--  作者:qq603310948
--  发布时间:8/31/2007 11:02:00 PM

--  
<!--这里的mytype代表你自己定义的类型,
type="xs:string"代表系统自带的string类型
name="id属性名
name="class"元素名
use="required"代表属性必须出现 和dtd #required类似
-->

<xs:element name="class" type="mytype"/>
<xs:complexType name="mytype">
    <xs:attribute name="id" type="xs:string" use="required">
    </xs:attribute>
</xs:complexType>


--  作者:lish
--  发布时间:9/12/2007 4:09:00 PM

--  
thans very much
--  作者:yihoo
--  发布时间:10/2/2007 4:30:00 PM

--  
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="school">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="class">
     <xs:complexType mixed="true">
      <xs:attribute name="id" type="xs:string"></xs:attribute>
     </xs:complexType>
    </xs:element>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
</xs:schema>
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
6,544.922ms