2011-05-27
GDom Progress
I'm grateful for the ideas provided in the comments on my last post. I didn't have enough time to thoroughly consider them all by today, so I'm just going to discuss where GDom is at now.
Learning
I've used the Vala tutorial to acquaint myself with some of its finer points. I welcome recommendations for other best practises when writing code in Vala, though.
I've also played with the older libgeexml recently to observe an example of libxml2 getting wrapped and abstracted in Vala. This entailed a lot of changes to get it to compile again (a lot in Vala has changed over a few years), which are currently available at a gitorious repo. I'll check if there's still interest in the project before polishing a patch set and sending it to git.gnome.org.
Prototyping
After this past week, we can now load an XML file and traverse its node structure. I went about creating a bunch of stub classes, and trying to implement the Document and Node DOM interfaces to start. Again, since GDom is initially relying on libxml2 (concerns about its memory consumption have been noted) for its back-end functionality, a lot of the work involved simply transforming data into user-friendly GObjects.
The code right now is available at the GDom gitorious repository. The initial commits have been large lumps, and the code base still requires a lot of massaging and stub-filling.
Issues
I encountered some issues having GDom's Attributes implement the same Node interface as all the other nodes, like the DOM API wants. Mostly because libxml2 treats its attributes as slightly distinct from its nodes. I also had a headache in trying to keep the attributes synchronised for a node between the GDom and the libxml2 representations, since the DOM API wants us to provide something like a HashTable (a NamedNodeMap) to users, but I want to keep that and the backing libxml2 structure in sync. I had originally hoped there would be easy signals to catch, but now I just have to be careful to sync them at the right time. I also have to take some care to avoid creating multiple distinct GDom Nodes for the same libxml2 node. I'd like a 1-1 relationship here.
The wonderful Alberto Ruiz has provided good guidance on all my questions so far, though, helping ensure GDom and I can continue to move forward :)
Next Week
Try to get Document and Node much more complete. This involves implementing more of other classes, too. The Document interface defines a bunch of methods for creating other elements, for example, so even if they don't function perfectly, I still want to have a dumb version for Document to handle.
Also, quite importantly, I'm going to create tests for Document and Node to start. Right now, I have a simple main () function that uses them to load an XML file and navigate it. I would like to have a more complete test package available to guide GDom's progress, though.
Also, finish considering and addressing comments left on my last post. I've read them all, and some of them warrant replies. Thank you for the feed back already. (I'll note that I'm busy this weekend, and won't get back to it until Monday, though.)
Also, I need to fill out more of http://live.gnome.org/XML. It's still a little sparse.
Have a good week.
2011-05-25
Hello GNOME. Meet GDOM.
GDOM
Good day. GNOME has many beautiful APIs. For manipulating XML, many projects use the powerful libxml2. However, its API is not consistent with GNOME conventions. It uses different data types, and does not benefit from good integration with GLib, missing out on libraries like GIO.
GDOM is an effort to implement the DOM Level 1 Core API for GLib.
- GObject API and GLib integration
- All objects, such as Nodes, Documents, and Attributes, will be GObjects. They'll use GErrors for exception handling, handle GIO's GInputStreams, etc.
- Functionality via libxml2
- We are not implementing the API from scratch. In fact, almost all its functionality is coming from libxml2, which is already robust and has good performance.
- Vala
- GDOM will be implemented in Vala which should help minimise the work necessary to complete the API.
I really want to hear your thoughts on XML and GNOME. I am at a disadvantage of never having had to write anything too large or intensive that used XML, just parsing and building simple files for my own projects. If you're involved with a project that already uses libxml2 (or another XML API), let me know. I'd like to see how you use it and how GDOM might make life better for you.
GSoC and Me
This is a Google Summer of Code 2011 project, and my mentor is Alberto Ruiz. Me? I'm a Masters student at the University of Guelph. I fell in love with GNOME about 7 years ago, but never got around to writing much code until 2009. My Masters has kept me busy recently, but thanks to Google, I can justify focusing on GNOME for a while :)