|
[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Fwd: dtd to c struct conversion
This whole area is known as as "XML data binding". It is far more highly developed for Java than any other language. See http://java.sun.com/xml/jaxb/ or http://www-106.ibm.com/developerworks/library/data-binding2/ 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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/ht 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:majordormo@w...] > Sent: Sunday, October 07, 2001 11:29 AM > To: xml-dev > Subject: 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? > > Info: > 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> >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|
|||||||||

Cart








