[Cosmo-dev] simplifying eimml
Brian Moseley
bcm at osafoundation.org
Fri Dec 1 11:54:14 PST 2006
On 11/30/06, Phillip J. Eby <pje at telecommunity.com> wrote:
> I understand that it may seem like a bit more effort to try to do the stuff
> Cosmo "understands" in EIM, but if I may suggest, it might be easier if you
> create simple objects that represent EIM abstractions like records, and
> have an EIM<->XML converter. Then, for the static schema you want to
> access, just pull it out of the EIM record objects. While this may be
> slightly more work than direct XML access, it will make it easier to handle
> changes to that "static" schema, because you will just change what EIM
> records you pull stuff out of.
yea, that's the approach i came up with last night.
> Anyway, I guess I'm suggesting that you could think of it as being like SAX
> for EIM, except that you have some kind of lookup mechanism to determine
> what to instantiate or invoke for each record type.
hehe, more like stax for eim ...
// InputStream in comes from servlet request
EimmlStreamReader reader = new EimmlStreamReader(in);
// translator builds up a list of item states, applying each record to
an item state based on uuid
EimTranslator translator = new EimTranslator();
while (reader.hasRecords())
translator.translate(reader.nextRecord();
// item state knows how to apply a state diff to an item
for (EimItemState state : translator.getTranslatedItemStates())
state.applyTo(findItem(state.getUuid()));
More information about the cosmo-dev
mailing list