Search code examples
xmlvalidationtypesxsdabstract

XML type definition can not be abstract, no non-abstract type in xsd


I got an external xsd I want to create an valid xml to. The xsd contains a complex type definition:

<xsd:complexType name="STE_SomeType" abstract="true">
      <xsd:simpleContent>
         <xsd:extension base="xsd:string"/>
      </xsd:simpleContent>
   </xsd:complexType>

The problem is, there is no non-abstract type extending STE_SomeType I could use when creating the xml. So if I create a xml with:

<Foo xmlns:dat="http://www.example.com/namespace/datatype" xsi:type='dat:STE_SomeType'>abc</Foo>

I get an validation error "Error:(48, 89) cvc-type.2: The type definition cannot be abstract for element Foo." And I just don't know what I need to give as xsi:type to get a valid xml since there is no fitting complex type in the xsd.

Is there a way to use the fact that STE_SomeType has simpleContent xsd:string or can I define something like a "private type" extending STE_SomeType in the xml?


Solution

  • If the schema contains an abstract type and no concrete restrictions of that type, then it looks as if the authors of the schema intended you to extend it with your own concrete restrictions of the type - otherwise the abstract type would serve no purpose.