Hi Dennis,
Very good analysis of the strengths and weaknesses of frameworks that I
fully support,
(if you look carefully my post you'll notice an interrogation mark near
SAX)
[can I integrate it in my lectures :) ?]
However, I do believe that a library can cover the spectrum from
generic document model (DOM) to specific data binding (java or xml centric).
Upto a certain extent Castor was able to use both approach, however since
it does not keep the original document (correct me if I am wrong) which
implied
that it was impossible to add DOM features and quite difficult to add
xpath alike accessor.
(which motivated my switch to XMLBeans)
AFAIK, it also requires developers to use classes generated from
schema for the data binding operation, making it one of the few data
binding frameworks that offers no support whatsoever for working with
ordinary Java classes.
Maybe someone can imagine a way to integrate standard classes
into an XMLBeans framework, this will probably imply to automatically
generate a schema from the classes (should not be too difficult) and
to provide on demand the XML document. Specific annotations or interfaces
may enable to modify the generic binding.
Ideally, the document should be tagged to keep track that, in this case,
the main data representation is in java and that any modification of
the document
should be done in the object too (which may be more problematic).
The questions are :
- is it worst the job ?
- will it not be more difficult for the developer ?
- will the performance overhead be not too prohibitive ?
Sorry for the noise :)
jc
side note : how can you agree with someone who is willing to replace
reflection with compiled code :P ?
Dennis Sosnoski wrote:
Hi jc,
This seems a lot like saying "it's really annoying to have to use
cars, boats, and planes to get places - why don't people just build a
single device that replaces all of these?" :-)
There are a lot of overlaps between the different frameworks for
working with XML in Java, but also a lot of differences. At the parser
level, SAX and StAX are fundamentally different. The document model
differences are more cosmetic - DOM, JDOM, dom4j, XOM, etc. are all
basically just variations of a tree API. When you get to data binding,
the differences are again very real.
I see mapped binding approachs as being fundamentally Java-centric,
where you add the XML data binding in an aspect-oriented fashion to
your existing Java classes. Castor used this approach originally, and
still supports it, but JiBX offers greater flexibility (as well as
much better performance than Castor). JAXB 2.0 also offers limited
support for mapped bindings, using annotations in code.
The other type of approach is code generation from schema, which is
inherently schema-centric. Most data binding frameworks support this
approach, though with different limitations on the schema constructs
supported.
XMLBeans really crosses the framework classes, in that it combines a
document model with data binding (perhaps more accurately, it builds a
data binding facade on a document model architecture). This gives it
unique strengths, especially for developers who need to access the
full structure of the XML but also want to access typed data values
through Java objects. It also makes for some weaknesses - XMLBeans
generally uses a lot more memory than conventional data binding
frameworks, and operates considerably slower (especially when reading
or writing data through the data bound objects). AFAIK, it also
requires developers to use classes generated from schema for the data
binding operation, making it one of the few data binding frameworks
that offers no support whatsoever for working with ordinary Java classes.
- Dennis
Jean-Christophe Pazzaglia wrote:
Hi,
I am involved on XML Programming since 98
and back in 99 (my first lecture on the topic)
I was already wondering why someone was not
able to provide a common framework to 'program' XML.
6 years later it seems that we still have to use different
libraries for different needs, I moved to XMLBeans from
Castor because I thought that XMLBean was more promising
(notably the integration with xpath and that it keeps the original
document,
while probably Castor is better as doing customized and schemaless
mapping)
and I am still fighting integrating code using DOM with my XMLBean
library, so I am simply wondering :
is it not possible to have one framework (let's say XMLBean++) able
to provide the solution (e.g integrating JAX*) , providing handy switch
between the different programming model (so I can use it as a
SAX(?)/DOM/JDOM
provider and switch idiom when needed [I know it may not be so simple
...])
jc
from
Your best choice is probably JiBX (http://www.jibx.org). JiBX is the
fastest XML data binding framework (https://bindmark.dev.java.net/),
and lets you work with existing classes. You can use the binding
generator from the tools subproject to generate a default binding from
your existing classes, then customize that if necessary to get exactly
what you want.
If you have questions about JiBX, join up on the JiBX users mailing
list (http://sourceforge.net/mail/?group_id=69358) and send the
questions there.
- Dennis
Zhong ZHENG wrote:
Hi,
Thanks for your advice. But the format of my XML file is already
defined, although i did not create schemas. If necessary, i may
create schema for my XML. But i do not want to use XMLBeans-generated
classes. So is it possible to do the data binding by using my own
java beans?
Regards.
On 10/22/05, *Giedrius Trumpickas* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
If you don't have schemas defined for your XML and have already
existing beans use:
http://xstream.codehaus.org/
Giedrius
--
ZHENG Zhong
1 Avenue Alphand
75116 Paris, France
+33 6 76 80 45 90
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Jean-Christophe Pazzaglia, PhD <[EMAIL PROTECTED]>
Network Security Team
Tel: (+33) 4-93-00-26-78
PGP Key available : http://www.eurecom.fr/~pazzagli/publickey.pgp
--
Institut Eurécom - Office 029
http://www.eurecom.fr/
2229 Route des CrĂȘtes
BP 193
06904 Sophia Antipolis, France
Fax: (+33) 4-93-00-26-27
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]