W3C home > Mailing lists > Public > xmlschema-dev@w3.org > September 2005

Re: tools generating classes from schema

From: Boris Kolpackov <boris@codesynthesis.com>
Date: Wed, 7 Sep 2005 11:09:10 +0200
To: Paul Kiel <paul@hr-xml.org>
Cc: xmlschema-dev@w3.org, wsinterop@lists.hr-xml.org
Message-ID: <20050907090910.GA10267@karelia>
[Apologies if this is the second copy you received.]


Here is the information about xsd, an XML Schema to C++ translator.
You can find out more about this tool at


Paul Kiel <paul@hr-xml.org> writes:

> The key constructs that cause problems when creating classes are:
> 1) xsd:union.  - This is the least supported feature of our schemas. We
>    had already been considering removing these as bad design anyway, so
>    this may add some force to that effort.

This is not supported.

> 2) xsd:pattern  - This is supported by some tools and not others.

This is supported.

> 3) having an element and a type with the same name.

There are two cases to consider. The first is when a global element
and a global type have the same name, e.g.,

<xsd:complexType name="hello"/>
<xsd:element name="hello" type="hello"/>

This case is supported.

The other case is when a type and an element inside this type have
the same name:

<xsd:complexType name="hello">
    <xsd:element name="hello" type="xsd:string"/>

This case is not supported.

> (also a problem even if casing is different, as in a "MyType" element and
> a "mytype" attribute)

There is no such problem in xsd.

> 4) recursive content models

This is supported.

> Other oddities that only cause problems in some tools:
> 5) extension of complexTypes - XSDObjectGen in particular has a problem
> with this, which seems odd as this is a major design feature of xml schema.

Works as expected.

> 6) simpleContent extension using a xsd base type

Works as expected.

> 7) reserved keyword element names (such as "Value")

All identifiers are properly escaped. Note that besides keywords, you may
also want to check for characters that are illegal in identifiers in most
programming languages but legal in XML Schema (e.g., '-').

> 8) too many anonymous types can lead to some class name collisions when
>    classes are generated

There is no such problem in xsd since all anonymous types are mapped to
nested types (i.e., we don't "flatten" the object model). For example,
this XML Schema definition

<xsd:complexType name="hello">
    <xsd:element name="name">

will result in the following C++ class definitions:

class hello
  class name


> 9) enumerations in elements (enumerations in attributes worked fine.
>    wierd but true for a tool to remain nameless)

Works as expected. Also note that we map XML Schema enumerations to
C++ enums.

> Here are features we don't even use, so we can't comment on (but suspect
> there may be possible problems):
> A) substitutionGroups

Not yet supported. We however plan to support this along with other instance
polymorphism mechanisms (e.g., xsi:type).

> B) redefine

Not supported. Note that this is one of the "questionable" features of XML
Schema (along with unions, as you pointed out) that don't map cleanly to the
target programming language.

> C) abstract types

Somewhat supported. Right now we simply ignore this attribute since it is
more of a validation feature. I guess we could make the generated d-tor
pure virtual to make the type non-instantiable.

> D) nillable

Can be supported should there be any interest.

> E) complexType restriction

Not supported. There is no natural mapping of this feature to the object
model of the target programming language. In particular, if we map
restriction to inheritance then we break the substitutability principle
(the derived-by-restriction type is-not-a base type). Probably the best
approach would be to generate a completely unrelated type.

> F) list types

Can be supported should there be any interest.

You may also want to check the "planned feature list":



Received on Wednesday, 7 September 2005 09:16:56 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:08 UTC