OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Achieving object model independence




Hi,

I would like to solicit the list's opinion about the best way to achieve 
object model independence in a library that makes use of XML at a higher 
application level. Specifically, I have a Swing-based implementation of 
xforms, and it is currently based on DOM (Xerces). I would like to change 
it so that it will work not only with Xerces, but with dom4j, JDOM, or any 
other object model.

There are three possibilities I'm currently looking at:

1. Build a Navigator similar to that in use by Jaxen/Saxpath, only mutable, 
and pass that around instead of documents/elements/attributes/etc.

2. Create my own set of basic interfaces that mirror common object model 
components (Document, Element, Attribute), subclass the implementation 
classes of the corresponding dom4j/JDOM/DOM classes, set the appropriate 
factory methods to create instances of the subclasses that implement my 
common interfaces, and return those common interfaces to the rest of my 
library.

I currently use this method with Xerces in order to implement undo/redo of 
DOM mutations, and it is quite effective. Nevertheless this approach makes 
me uneasy because it is dependent on utilizing "nonpublic" components (that 
is, having to subclass the default implementation classes which, though 
often public in the sense of Java scoping, are sometimes left out of 
documentation and presumably more subject to change than the rest of the 
APIs. Is this true, or am I being overly worrisome?)

3. Similar to 2 in that I create my own set of basic interfaces that mirror 
common object model components, but instead of the subclass/factory scheme, 
make wrappers around the implementation classes of the corresponding 
dom4j/JDOM/DOM classes, and again return those common interfaces to the 
rest of my library.

My questions are:

1. Is there a better method that I'm overlooking?

2. How are other people tackling the problem of object model independence 
in cases where higher level libraries might be used in different contexts 
with different object models?

I would very much appreciate any expert advice and insights into this 
problem, and how it can be best approached, and maybe hearing that this is 
an easily (and perhaps already solved) problem...  :)

Many thanks in advance,
Jim


--
www.jbrix.org
Open Source Software
Java - XML - Speech Recognition