Reputation: 106904
I have an XML schema which I need to process and in the middle of it there is this line:
<xsd:complexType name="SomeName"/>
Is this valid XSD schema, or should a complexType
always have some kind of content (child elements, attributes, anything)?
Upvotes: 2
Views: 3834
Reputation: 3724
Yes this is a perfectly valid 'empty element'. Often used as a 'flag'. Take a look at http://www.w3schools.com/schema/schema_complex_empty.asp. That example includes a type with an attribute, but the discussion is valid.
[EDIT - new URL] https://www.w3schools.com/xml/schema_complex_empty.asp
Upvotes: 1
Reputation: 43651
Yes, it is valid.
See the schema for the schema.
<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>
So the minimum would be:
<xs:complexType name="someNCName"/>
Which is the case in your question.
Upvotes: 3