Convertor wanted: C struct to XML schema

Trevor Croll litebook at powerup.com.au
Wed Jul 28 02:56:18 BST 1999


I am doing an application that seems similar to yours,
I am still studying and learning and this is my current conclusion.

XML data is parsed by a SAX parser with a DOM interface used to build a DOM
tree.
There is no need for a C struct for an XML document, use a DOM tree
by walking this tree the field details can be pulled into your app as you
need them.
Data in the DOM tree can be changed and nodes added as required.
The DOM tree can then be scanned and turned into XML data for transmission

References - http://www.python.org/ have a XML addition which is very
instructive though different for your requirements
http://www.alphaworks.ibm.com/  offer source code and a C++ Builder example
XML4C

I have worked through this and now looking very closely at all the DOM
literature and COBRA literature to properly aquaint myself with this.

http://www.jclark.com/xml/xp/index.html has an SP parser and a Jade parser
which I will be looking closely at

I must admit there is very little guidance and overview documents detailing
how all the parts and bits of XML are intended to fit together with each
other.




----- Original Message -----
From: Tan Yiping <tanyp at mail.conuco.cn.net>
To: <xml-dev at ic.ac.uk>
Sent: Tuesday, July 27, 1999 3:11 PM
Subject: RE: Convertor wanted: C struct to XML schema


> 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
> two
> 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,
> filling
> 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; file://Price in United States
> float fDM; file://Price in Germany
> }T_Price;
>
> typedef struct {
> char szName[8]; file://Newspaper name
> long nSubscription; file://Number of Subscription
> T_BundleParam tBundleParam; file://6 Bundling parameters
> T_Price tPrice; file://Price
> }T_Newspaper;
>
> 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"
> xmlns:dt="urn:schemas-microsoft-com:datatypes">
> <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>
> <ElementType name="Newspaper" content="eltOnly">
> <element type="Name"/>
> <element type="Subscription"/>
> <element type="BundleParam" minOccurs="1"
> maxOccurs="*"/>
> <element type="Price"/>
> </ElementType>
> </Schema>
>
> (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
> the
> syntax correctly!
>
> Is such a tool exist?
>
> Yiping
> (Chinese has their given names at last position. There isn't an
> international
> standard on name format yet, sorry.)
>
>
> xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
> Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on
CD-ROM/ISBN 981-02-3594-1
> To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
> (un)subscribe xml-dev
> To subscribe to the digests, mailto:majordomo at ic.ac.uk the following
message;
> subscribe xml-dev-digest
> List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
>
>


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





More information about the Xml-dev mailing list