On Mon, 4 Aug 2003, Angus Leeming wrote: > Like I said, I know how to go about it. I can also see that this would be > useful functionality. However, my question boils down to, "Is it > extendable?" Which is another way of asking, "What is the grammar?"
Oh, I beg you, don't go down that road. This will do just fine: lastExternalTemplate = "xfig" > Given that there seems to be a push to use xml for the lyx file format, it > seems reasonable to not invent yet another language where xml will fit the > bill. However, my knowledge of xml is very limited and I don't want to > reinvent the wheel here. XML is totally overkill for this. XML is way too complicated for a simple task like this. There is no need for complicated namespaces or deeply nested data structures for something as simple as this. You are smacking a fly with a small nuke. > So, what should we use to do the input/output? A quick search of google > throws up lots of GNU-compatible libraries. The first three are: > libxml2 http://xmlsoft.org/ > The Common C++ library http://www.gnu.org/software/commonc++/ > Sablotron http://www.gingerall.com/charlie/ga/xml/p_sab.xml I have worked with XML for three years professionally now, and am continuously monitoring the technology to do this. Most of my experience comes from the Xerces brand of parsers, because those are ironically the most mature, even though they are leaking, slow as hell, error-prone and generally of low quality, because XML is so complicated. There are no good C++ XML parsers so far. They are basically all primitive and derived too closely from the Java DOM or the SAX APIs. The fit to C++ is terrible and very much crammed in to kind of fit with a big sledgehammer. The overhead of these parsers is ridiculous (due to memory trashing), and the code written to those APIs is butt-ugly and hardly maintainable. XML and C++ is simply a bad match at this point in time. Researchers are struggling to embed XML naturally even in toy research languages. In practice, the Java people are the most advanced, but they are not very good yet. The best research bindings so far are the XDuce brand - but those are still relatively young and immature. And even the best C++ bindings are light-years behind what those systems do. See for instance http://citeseer.nj.nec.com/593778.html I can understand that you want to investigate XML and learn that. Do that, but you'll find that it is hyped a lot. XML equals bloat, and performance problems. There is a terrible match to current type systems in todays programming languages. You loose performance, and the ordinary unix text tools have serious problems. You can't grep xml files, and no practical substitute exists. diff does not work, patch fucks up, and you can not even read the files, or edit them in real life. XML can give you a benefit if you want to interoperate with other pieces of software where you have a defined DTD or XSchema that will help you exchange information. That is hardly the case here. Yes, you can transform XML documents with XSLT, but that language is too braindead to begin with, and it's faster to use regexps and a decent language instead. And this is hardly the case here. If you think a simple (key, value) file is too simple to be fun, then my proposal would be to bundle up a Lua interpreter, write the data as Lua files, read them in and be done with it as that. You can even use the syntax I wrote up above directly as it is. All of this you can do at a fraction of the bloat an XML parser will incur, and you get a super-cool programming language at the same time, with natural syntax tailored for data and text description and processing (including regexps), first order functions, a tight and efficient language that is meant for embedding, with *excellent* C++ binding technology that rocks your socks off XML any time. The entire Lua interpreter takes up a whole whoping 50 kb when compiled with optimisations. It will do you good, and the geek factor is way up there. Check out www.lua.org, and after that luabind at luabind.sourceforge.net. XML is still young technology compared to this. Give XML three or four years, and then you might want to have a look again. Best regards, Asger