[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [xml-dev] Fwd: dtd to c struct conversion
- From: "Champion, Mike" <Mike.Champion@SoftwareAG-USA.com>
- To: xml-dev <email@example.com>
- Date: Sun, 07 Oct 2001 13:47:27 -0400
This whole area is known as as "XML data binding". It is far more highly
developed for Java than any other language. See
But that probably doden't help you much as a C programmer :~) I can't find
anything on doing XML data binding in straight C.
Ron Bourret has (as usual!) the definitive summary/links on the data binding
in general http://www.rpbourret.com/xml/XMLDataBinding.htm
Ron does mention one C++ product http://www.schematoolkit.com/
that may or may not be of use. There's also a MSDN page at
m/xmtuttut9usingthecxmldso.asp on how to do this, but I
suspect it is of even less use to Linux programmers.
BUT as far as I know, you could only do what you want to do with a very
limited subset of DTDs, those that contain a fixed number of every element,
don't allow mixed content, and so on. Ron Bourret's page says: "Most XML
data binding products are data-centric. That is, they are not capable of
fully representing XML documents as objects or objects as XML documents. In
the former case, most cannot handle mixed content or the order of child
elements and text in their parent, and also ignore things like comments,
processing instructions, and entities."
I'd guess that your best bet would be to write a small SAX application
(there *is* a C version, see http://xmlsoft.org/) that loads XML data into a
struct that you define. If the DTD is more "interesting" (i.e., it allows
mixed content, recursion, arbitrary order of elements, entities, etc.) it
might be easier to load the XML into a DOM tree and write code that seeks
out all the places that the data for your little struct could be hiding in
the XML tree.
> -----Original Message-----
> From: Marcus Hardt [mailto:firstname.lastname@example.org]
> Sent: Sunday, October 07, 2001 11:29 AM
> To: xml-dev
> Subject: [xml-dev] Fwd: dtd to c struct conversion
> Hi There!
> I've got the problem, that I want to be able to read a dtd
> and write that
> definition into a C struct. That should enable me to read any
> xml-file whose
> dtd is known at compile-time.
> Is there such a tool?
> If not: Is there any hints for the way programming it in C?
> I use the Expat for parsing (just because I didn't think
> about libxml yet.
> Should I reconsider this decision?)
> I run it on Linux (of course)
> Regards, Marcus
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> The list archives are at http://lists.xml.org/archives/xml-dev/
> To subscribe or unsubscribe from this elist use the subscription
> manager: <http://lists.xml.org/ob/adm.pl>