以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 DTD/XML Schema 』  (http://bbs.xml.org.cn/list.asp?boardid=23)
----  [求助]想要一个Schema文件及与其配套的XML文件  (http://bbs.xml.org.cn/dispbbs.asp?boardid=23&rootid=&id=59742)


--  作者:xccx
--  发布时间:3/11/2008 11:20:00 AM

--  [求助]想要一个Schema文件及与其配套的XML文件
如题,因为最近要写段将Schema文件转为模式表的程序,需要个可以让我进行验证的例子,我对XML是完全新手,请问论坛哪位能不能随便给我一个schema文件?不用太大,几百行就行,

     最好有由该Schema文件生成的XML文件,我可以更方便验证程序正确性,没有也可以凑合,

     我的邮箱是chenx212@gmail.com,谢谢各位了!


--  作者:jinscott
--  发布时间:3/21/2008 10:52:00 PM

--  
Schema文件


<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2005 sp2 U (http://www.altova.com) by any (Ru-Board) -->
<!-- edited with XML Spy v4.4 alpha 1 U build Jun 28 2002 (http://www.xmlspy.com) by Altova (Altova) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="学生列表" type="学生列表类型"/>
 <xs:complexType name="学生列表类型">
  <xs:sequence>
   <xs:element name="学生信息" type="学生信息类型" maxOccurs="100"/>
  </xs:sequence>
 </xs:complexType>
 <xs:complexType name="学生信息类型">
  <xs:sequence>
   <xs:element name="学生姓名" type="学生姓名类型"/>
   <xs:element name="学生性别" type="学生性别类型"/>
   <xs:element name="学生生日" type="学生生日类型"/>
   <xs:element name="联系方式" type="联系方式类型"/>
   <xs:element name="学生分数" type="学生分数类型"/>
  </xs:sequence>
  <xs:attribute name="学生编号" type="学生编号类型"/>
 </xs:complexType>
 <xs:complexType name="联系方式类型">
  <xs:choice>
   <xs:element name="电话号码" type="电话号码类型"/>
   <xs:element name="家庭住址" type="家庭住址类型"/>
   <xs:element name="QQ号码" type="QQ号码类型"/>
  </xs:choice>
 </xs:complexType>
 <xs:simpleType name="学生编号类型">
  <xs:restriction base="xs:ID">
   <xs:pattern value="HK\d{4}"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="学生姓名类型">
  <xs:restriction base="xs:string">
   <xs:maxLength value="4"/>
   <xs:minLength value="2"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="学生性别类型">
  <xs:restriction base="xs:string">
   <xs:enumeration value="男"/>
   <xs:enumeration value="女"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="学生生日类型">
  <xs:restriction base="xs:date"/>
 </xs:simpleType>
 <xs:simpleType name="学生分数类型">
  <xs:restriction base="xs:int">
   <xs:maxInclusive value="100"/>
   <xs:minInclusive value="0"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="电话号码类型">
  <xs:restriction base="xs:string">
   <xs:pattern value="1[3,5]\d{9}"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="家庭住址类型">
  <xs:restriction base="xs:string">
   <xs:minLength value="4"/>
  </xs:restriction>
 </xs:simpleType>
 <xs:simpleType name="QQ号码类型">
  <xs:restriction base="xs:string">
   <xs:pattern value="\d{5,9}"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>

配套的XML文件

<?xml version="1.0" encoding="UTF-8"?>
<学生列表 xmlns:tsd="http://namespaces.softwareag.com/tamino/TaminoSchemaDefinition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="students.tsd">
 <学生信息 学生编号="HK1001">
  <学生姓名>张三</学生姓名>
  <学生性别>女</学生性别>
  <学生生日>1987-07-07</学生生日>
  <联系方式>
   <电话号码>1592589456</电话号码>
  </联系方式>
  <学生分数>80</学生分数>
 </学生信息>
 <学生信息 学生编号="HK1002">
  <学生姓名>张三</学生姓名>
  <学生性别>女</学生性别>
  <学生生日>1987-07-07</学生生日>
  <联系方式>
   <QQ号码>123456789</QQ号码>
  </联系方式>
  <学生分数>80</学生分数>
 </学生信息>
</学生列表>


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