Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert XSD to Delphi classes?

7,159 views
Skip to first unread message

Arthur Hoornweg

unread,
Mar 31, 2008, 5:27:02 AM3/31/08
to
Hello all,

does anyone know of a tool to generate Delphi code (classes, enums)
from XSD schema files? I use Delphi 2007 professional.
I tried to write a tool myself, but the Delphi object model knows only
methods and properties, not attributes, so I'm kinda stuck.

The XSD's that I need to convert are extremely complex and nested,
you can find them at the following location:
http://www.witsml.org/schemas/1311/doc/WITSML_Schema_docu.htm


--
Arthur Hoornweg

(In order to reply per e-mail, please just remove the ".net"
from my e-mail address. Leave the rest of the address intact
including the "antispam" part. I had to take this measure to
counteract unsollicited mail.)

Kevin Frevert

unread,
Mar 31, 2008, 1:55:56 PM3/31/08
to
Arthur,

You will need an Enterprise version of Delphi that includes the XML
Databinding Wizard. If the XSD references other XSDs (such as datatypes
defined in one, complex types declared in another, etc) the databinding
wizard will not work.

In one situation, I created my own 'proxy' XSD that wrapped up the important
'stuff' from multiple schemas and generated a class from that. Since the
target service only sees the XML string, how the XML is generated is/was
irrevalant.

Good luck,
krf

"Arthur Hoornweg" <antispam...@casema.nl.net> wrote in message
news:47f0ae66$1...@newsgroups.borland.com...

Mikael Eriksson

unread,
Apr 1, 2008, 2:19:47 AM4/1/08
to
Kevin Frevert skrev:

> You will need an Enterprise version of Delphi that includes the XML
> Databinding Wizard.

The XML Databinding Wizard is available in Professional.

In the feature matrix it is called "BizSnap native XML bindings to
simplify XML programming - access XML document as Delphi object"

http://www.codegear.com/article/36898/images/36898/radstudio-fm.pdf

regards

/Micke

Bob Swart

unread,
Apr 1, 2008, 11:22:07 AM4/1/08
to
Hi Arthur,

> does anyone know of a tool to generate Delphi code (classes, enums)
> from XSD schema files?

Check out the Data Binding Wizard, which could be just what you need...

See http://www.drbob42.com/examines/examin23.htm or (in Dutch)
http://www.ebob42.com/papers/xml.htm

Groetjes,
Bob Swart

--
Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi
CodeGear Technology Partner -- CodeGear RAD Studio Reseller (BeNeLux)
Personal courseware + e-mail support http://www.ebob42.com/courseware
Blog: http://www.drbob42.com/blog - RSS: http://eBob42.com/weblog.xml

Arthur Hoornweg

unread,
Apr 2, 2008, 8:41:40 AM4/2/08
to
Bob Swart wrote:
> Hi Arthur,
>
>> does anyone know of a tool to generate Delphi code (classes, enums)
>> from XSD schema files?
>
> Check out the Data Binding Wizard, which could be just what you need...


Thank you all for answering.

The data binding wizard doesn't handle nested/chained XSD files.
Fortunately, the test application that I wrote a few days earlier merged
them into a single document anyway, so it was just a matter of storing
the composite file into a new huge utf8 encoded XSD file and feeding
it to the xml data binding wizard.

I now have a Delphi unit with lots of interfaces.

Unfortunately, the data binding wizard maps every property as "widestring"
and discards all constraints etc. The end result is unusable.

Stefan M. Huber

unread,
Apr 2, 2008, 8:53:08 AM4/2/08
to
On Wed, 02 Apr 2008 14:41:40 +0200, Arthur Hoornweg
<antispam...@casema.nl.net> wrote:

> Bob Swart wrote:
>> Hi Arthur,
>>
>>> does anyone know of a tool to generate Delphi code (classes, enums)
>>> from XSD schema files?
>> Check out the Data Binding Wizard, which could be just what you need...
>
>
> Thank you all for answering.
>
> The data binding wizard doesn't handle nested/chained XSD files.
> Fortunately, the test application that I wrote a few days earlier merged
> them into a single document anyway, so it was just a matter of storing
> the composite file into a new huge utf8 encoded XSD file and feeding
> it to the xml data binding wizard.
>
> I now have a Delphi unit with lots of interfaces.
>
> Unfortunately, the data binding wizard maps every property as
> "widestring" and discards all constraints etc. The end result is
> unusable.

Is the XSD publicly available? If so, you could provide it for the
developers to see it. I have some XSD files myself that I...well...I don't
use the imported classes but create the XML manually in a string and read
the results with a XML document...

So if any developer would like to see in-the-wild schemata, I'll gladly
mail or post them.

Stefan

Arthur Hoornweg

unread,
Apr 3, 2008, 3:03:42 AM4/3/08
to
Stefan M. Huber wrote:

> Is the XSD publicly available? If so, you could provide it for the
> developers to see it. I have some XSD files myself that I...well...I
> don't use the imported classes but create the XML manually in a string
> and read the results with a XML document...

Yes, checkout
http://www.witsml.org/schemas/1311/doc/WITSML_Schema_docu.htm
and unzip the document. The offending file is "witsml_composite.xsd",
it links in all the other xsd files.

The problem seems to be that simple (int, float, string) types are
inherited
several times (introducing simple range restrictions each time). The xml
data mapper then loses track of the underlying type and declares it as
widestring.

0 new messages