JavaEOXMLSupport is now working!


I finally got a version of the JavaEOXMLSupport.framework working to the level that it could actually be used in a project. The previous version was usable for read-only cases, but was pretty useless for editing/writing XML.

I had to rethink the strategy a bit. The previous strategy treated every Element in a document as an individual EO. That works conceptually, because it's easy to model (you can model the XML schema in EOModeler, and use that, in theory - King even wrote a tool to generate an EOModel from a schema!) It's harder to implement this, however, because individual EOs are somewhat separated from the DOM - they don't know where they are within the DOM, etc... Also, in this model, it was very hard to add new elements to an existing document. Say a document didn't have a keyword when it was pulled from the database. This strategy makes it difficult to add a classification.keyword.string if there isn't one already... (how do you add an element into a DOM tree when you don't know where you are in that tree?)

The current strategy is to treat the XML document itself as the EO, and to teach the Key Value Coding methods in that EO class (EOXMLRecord) to dig into the DOM as needed, and provide a nicely wrapped EOXMLElement class for each DOM Element ( the EOXMLElement wrapper provides Key Value Coding interface on the DOM Element so it plays nicely with WebObjects). This 2-class strategy (one to integrate with EOF, one to integrate with DOM) also makes it drop-dead simple to add new elements - they're created on the fly when requesting their values, so it should Just Work if you try to add an element where there isn't one (like adding a new classification.keyword.string, for instance...)

I'm 100% sure there are some Hummer-sized caveats and special cases and bugs looming in there, but the hard part is done - it works! I'll clean up the code, write some documentation and sample apps, and update the Sourceforge project as soon as I get a chance (may not be until September, though, since I'm being simultaneously buried by the Pachyderm...)


See Also

comments powered by Disqus