The Delphi 2009 XML Data Binding Wizard fails to process a simple XSD which contains a complexContent declaration (Invalid Pointer Operation).
Is it a bug or a know limitation?
Example:
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema targetNamespace="http://example.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:complexType name="TestType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="Name" type="xsd:string"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
Edit: other examples work fine, so it looks like a part of the complexContent definition causes the error. Working example:
<xsd:complexType name="pc-Typ">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:integer"/>
</xsd:complexType>
<xsd:complexType name="myPC-Typ">
<xsd:complexContent>
<xsd:extension base="pc-Typ">
<xsd:sequence>
<xsd:element name="ram" type="xsd:integer"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Yes,
xsd:complexContentcan be used.I know Delphi has its flaws, but I don’t blame Delphi for this schema. XSD is a rich schema language, and so is Delphi’s OO class. Parts of two worlds overlap, but there are parts that won’t. XML databinding is an act of translating an XML schema into OO class structure, so the schema has to be concrete enough to be expressed as class.
In this example, you are saying that
TestTypematches any type so long as it has astringattribute calledName. An XML validator may be ok with that kind of definition, but it’s hard to define that in a single-inheritance model, sincefoo:Animal,foo:Plant, andfoo:Mineralmay all haveNameattribute.I defined an empty complexType called
TestBaseTypeand that generated class perfectly fine.This generated the following code: