Convertor wanted: C struct to XML schema

Tan Yiping tanyp at
Tue Jul 27 07:09:35 BST 1999

Thanks a lot to Steve, Mike, and John. Your information is very helpful.

However, none of tools you mentioned sovle exactly my problem. My last
message was too short, it seems. OK. Let me post a long one this time.
Hope you are still interested in this topic.

What I want to do basically is to exchange data in XML format between
applications over the network. Because XML docs are self-descriptive, it
should be intelligent enough to tolerate some independent interface
upgrading/extension in each of the communication partners. Quite a new
XML application, isn't it?

My current approach is to first define the data to be exchanged in XML
Schema. Then I can parse the XML Schema in (because it's a well-formed
XML doc) and generate XML doc against this schema in DOM objects,
with the data from the a C struct. The point is, when the XML Schema is
parsed in, I have the XML doc structure and variable names in memory.

Let's say I have in memory an instance of data "tNewspaper" of type 
T_Newspaper, defined as following:

typedef int T_BundleParam[6];

typedef struct {
	float	fUSD;		//Price in United States
	float	fDM;		//Price in Germany

typedef struct {
	char		szName[8];		//Newspaper name
	long		nSubscription;		//Number of Subscription
	T_BundleParam	tBundleParam;		//6 Bundling parameters
	T_Price		tPrice;			//Price

The XML counterpart of the above definition can be, in IE5-compatible
XML Schema language:

<?xml version="1.0"?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data"
	<ElementType name="BundleParam" dt:type="int"/>
	<ElementType name="USD" dt:type="real"/>
	<ElementType name="DM" dt:type="real"/>
	<ElementType name="Name" dt:type="string"/>
	<ElementType name="Subscription" dt:type="int"/>
	<ElementType name="Price" content="eltOnly">
		<element type="USD"/>
		<element type="DM"/>
	<ElementType name="Newspaper" content="eltOnly">
		<element type="Name"/>
		<element type="Subscription"/>
		<element type="BundleParam" minOccurs="1"
		<element type="Price"/>

(It will be perfect if I can define BundleParam as minOccurs="6"
maxOccurs="6". However, the MSXML parser in IE5 doesn't support so.)

Now I have made the above XML Schema manually. But I have hundreds
of such kind of C structs to be converted. It would be very helpful if
there is
a tool to do the conversion, even if the tool can only translate 80% of
syntax correctly!

Is such a tool exist?

(Chinese has their given names at last position. There isn't an
standard on name format yet, sorry.)

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list