.net下的schema语法

来源:互联网 发布:java专业技能描述 编辑:程序博客网 时间:2024/05/15 20:48

<xs:schema id="Question_Attributes_Schema"
                  targetNamespace="http://tempuri.org/Question_Attributes_Schema.xsd"
                  elementFormDefault="qualified"
                  xmlns="http://tempuri.org/Question_Attributes_Schema.xsd"
                  xmlns:mstns="http://tempuri.org/Question_Attributes_Schema.xsd"
                  xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--问题属性-->
<xs:element name="问题属性">
 <xs:complexType>
  <xs:sequence>
   <!--问题基本属性-->
   <xs:element name="问题基本属性"  type="Basic_Question"/>
   <!--问题扩展属性-->
   <xs:element name="问题扩展属性"  type="Extend_Question"/>
  </xs:sequence>
 </xs:complexType>
</xs:element>

<!--自定义"问题基本属性"类别-->
<xs:complexType name="Basic_Question">
  <xs:attribute name="id"    type="xs:integer"/>
  <xs:sequence>
   <xs:element name="问题标题"   type="Question_Basic_Attribute"/>
   <xs:element name="问题描述"   type="Question_Basic_Attribute"/>
   <xs:element name="问题类型"   type="Question_Basic_Attribute"/>
   <xs:element name="问题添加时间"  type="Question_Basic_Attribute"/>
   <xs:element name="问题编写者"  type="Question_Basic_Attribute"/>
   <xs:element name="问题解决方法"  type="Question_Method"/> 
  </xs:sequence>
</xs:complexType>

<!--自定义"问题扩展属性"类别-->
<xs:complexType name="Extend_Question">
  <xs:attribute name="id"    type="xs:integer"/>
  <xs:sequence>
   <xs:element name="问题点击量"  type="Question_Basic_Attribute"/>
   <xs:element name="相似问题链接"  type="Question_Basic_Attribute"/>
   <xs:element name="问题答案出处"  type="Question_Basic_Attribute"/>
   <xs:element name="编写者联系方式" type="Question_Connection"/>
  </xs:sequence>
</xs:complexType>

<!--自定义"问题解决方法"类别-->
<xs:complexType name="Question_Method">
  <xs:attribute name="id"    type="xs:string" />
  <xs:attribute name="isCheck"   type="xs:string" />
  <xs:attribute name="isChange"   type="xs:string" />
  <xs:sequence>
   <xs:element name="问题解决方法1" type="Question_Basic_Attribute"/>
   <xs:element name="问题解决方法2" type="Question_Basic_Attribute"/>
   <xs:element name="问题解决方法3" type="Question_Basic_Attribute"/>
  </xs:sequence>
</xs:complexType>

<!--自定义"编写者联系方式"类别-->
<xs:complexType name="Question_Connection">
  <xs:attribute name="id"    type="xs:string" />
  <xs:attribute name="isCheck"   type="xs:string" />
  <xs:attribute name="isChange"   type="xs:string" />
  <xs:sequence>
   <xs:element name="QQ"    type="Question_Basic_Attribute"/>
   <xs:element name="MSN"    type="Question_Basic_Attribute"/>
   <xs:element name="E-MAIL"   type="Question_Basic_Attribute"/>
  </xs:sequence>
</xs:complexType>

<!--自定义元素的属性类别:"id"为问题类别ID."isCheck"为问题类别属性是否"默认选择"."isChange"为问题类别属性"选中状态是否允许修改"-->
<xs:complexType name="Question_Basic_Attribute">
  <xs:attribute name="id"   type="xs:string" />
  <xs:attribute name="isCheck" type="xs:string" />
  <xs:attribute name="isChange" type="xs:string" />
</xs:complexType>

</xs:schema>
说明: 第一句中xmlns:xs="XXXXXXX"表示未命名的名称空间,elementFormDefault="unqualified"就是指XML文件没有资格使用默认名称空间。elementFormDefault="qualified"就是指XML文件有资格使用默认名称空间。 targetNamespace="http://tempuri.org/Question_Attributes_Schema.xsd"
表示被XML文件引用的名称空间