空的 complexType 在 XSD 中是否有效? [英] Is an empty complexType valid in an XSD?

查看:36
本文介绍了空的 complexType 在 XSD 中是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个需要处理的 XML 模式,中间有一行:

I have an XML schema which I need to process and in the middle of it there is this line:

<xsd:complexType name="SomeName"/>

这是有效的 XSD 模式,还是 complexType 应该始终具有某种内容(子元素、属性等)?

Is this valid XSD schema, or should a complexType always have some kind of content (child elements, attributes, anything)?

推荐答案

是的,有效.

有关架构,请参阅架构.

 <xs:complexType name="complexType" abstract="true">
  <xs:complexContent>
   <xs:extension base="xs:annotated">
    <xs:group ref="xs:complexTypeModel"/>
    <xs:attribute name="name" type="xs:NCName"/>
    <xs:attribute name="mixed" type="xs:boolean" use="optional" default="false"/>
    <xs:attribute name="abstract" type="xs:boolean" use="optional" default="false"/>
    <xs:attribute name="final" type="xs:derivationSet"/>
    <xs:attribute name="block" type="xs:derivationSet"/>
   </xs:extension>
  </xs:complexContent>
 </xs:complexType>

 <xs:group name="complexTypeModel">
  <xs:choice>
      <xs:element ref="xs:simpleContent"/>
      <xs:element ref="xs:complexContent"/>
      <xs:sequence>
       <xs:group ref="xs:typeDefParticle" minOccurs="0"/>
       <xs:group ref="xs:attrDecls"/>
      </xs:sequence>
  </xs:choice>
 </xs:group>

 <xs:group name="attrDecls">
  <xs:sequence>
   <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="attribute" type="xs:attribute"/>
    <xs:element name="attributeGroup" type="xs:attributeGroupRef"/>
   </xs:choice>
   <xs:element ref="xs:anyAttribute" minOccurs="0"/>
  </xs:sequence>
 </xs:group>

所以最小值是:

<xs:complexType name="someNCName"/>

您的问题是什么情况.

这篇关于空的 complexType 在 XSD 中是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆