dr jerry
dr jerry

Reputation: 10026

What is the use of XSD complexType without element reference?

I'm tasked with validating and interpreting and XSD Schema, this schema starts with:

<xsd:schema xmlns:xsd="http://....">
<xsd:complexType name="TemplateType"> <!-- Nowhere referenced -->
  <xsd:sequence>
    <xsd:element name="DataType" type="DocumentDataType"/>
  </xsd:sequence>
</xsd:complexType>
<xsd:complexType name="DocumentDataType">

It's been too long since my last XSD task, but somewhere I would expect a <element type="templateType">, but this is not the case.

What is wrong here? My rusty XSD knowledge or the delivered XSD?

Upvotes: 2

Views: 809

Answers (1)

kjhughes
kjhughes

Reputation: 111686

A complex type name (xsd:complexType/@name) could be

  1. Used to define the type of an element (xsd:element/@type), as you say.
  2. Used to define derived types via extension (xsd:extension/@base) or restriction (xsd:restriction/@base).
  3. Used in XSDs that include or import this XSD.
  4. Used in XML instances via xsi:type. [Credit @MichaelKay]
  5. Planned for future use in the current XSD.
  6. Simply be unused.

So, your TemplateType may serve another purpose besides the direct definition of an element type, or it may have become vestigial over the course of the evolution of the XSD.

Upvotes: 2

Related Questions