cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett McLaughlin <new.insta...@gte.net>
Subject Re: JDOM and Thank You :)
Date Thu, 27 Apr 2000 22:37:54 GMT


Keith Visco wrote:
> 
> Brett,
> 
> Personally your API looks very much like the W3C DOM. 

Hey Keith.  Actually, I'm surprised by that (and you're the first to say
that).  We don't do all the Node inheritance stuff (no getNodeType() or
instanceof), we don't treat everything as Nodes (element.getContent()
instead of element.getFirstChild().getValue()), we don't store the lists
as NodeList and NamedNodeMap, the only similarity is that we allow
random access to the document, in a tree-like format.

So yes, the concepts are the same.  One comment we receive a lot of is:

It's MUCH simpler to use than Xerces or DOM.  It's the
interface I expected when I first looked at org.w3c.dom.

We made things intuitive where we felt they were not.

And if you add
> back in the multi-directional (children/parents/sibling) node traversal,
> you are back to DOM. Of course you've added support for Namespace
> handling, which DOM level 1.0 doesn't address (mainly because it wasn't
> relavant at the time), but DOM level 2.0 does address.

Yes, but does it address it in an intuitive way?

getElementsByTagName()
getElementsByTagNameNS()

I would argue not, just based on these two methods - DOM has to be
supported in all sorts of languages, and so they didn't add in method
overloading, and things of that nature.  They also are extremely
heavyweight for large documents, and don't (yet, though its rumored to
be in DOM Level 3) specify anything about input and output - just how
the tree works once in memory.


> 
> One difference I do see is the Element#getContent() method. I actually
> don't like this because it removes document order, and I think any good
> "Document Object Model" (i.e. something modeling the document and not
> the data) should preseve document order.

You can still get that through getMixedContent(), which returns
Elements, Strings, Comments, Entities, etc.  However, it is much more
common to juse want the Textual value, and not to desire to do lots of
casting (to CharacterData, Text, CDATA, etc).  "Just give me the
value!"  However, getMixedContent() gives you everything, in an ordered
fashion, and you can deal with it how you like.

> 
> So unless I've failed to see something here, I don't understand what
> JDOM is actually providing which is supposedly better than DOM?

speed.  intuitive method calls (getChildren() returns the child elements
- no need for casting [for example]).  Java-centric contructs like List
and Map.  flyweight implementation.  etc.... (we have a whole website of
press - I don't want to drone on, as /maybe/ I'm a little biased ;-) )

> 
> Just my $0.02

Appreciated - you should hop onto jdom-interest and see how things are
coming - I think you'll see we are quite different from JDOM.

-Brett

> 
> --Keith
> 
> "Brett D. McLaughlin" wrote:
> >
> > Scott Boag/CAM/Lotus wrote:
> > >
> > > I don't believe JDOM will work with Xalan, or any other XSLT processors
> > > that I know of, unless you produce SAX events (or a DOM) from the JDOM.
> >
> > SAXOutputter and DOMOutputter do just that.  So you can use them with
> > any XML component that gives or receives DOM or SAX - that means pretty
> > much everything.
> >
> > > Xalan can't use JDOM internally, for one reason, because you can't traverse
> > > up from a Node, and, for another, I believe it is important for Xalan to be
> > > compatible with the DOM (including the interface model, which allows Xalan
> > > to walk many tree implementations).
> >
> > Today, I'd afree with you.  JDOM is too new.  But 6 months from now?
> > That may be a different story.  Additionally, we are discussing
> > traversing nodes right now, and if that is functionality that might be
> > needed.
> >
> > Cocoon should really use SAX2, and it
> > > should not care about tree object models, in my opinion.
> >
> > We'll see... SAX2 is a pain to code for - event handlers are great in
> > some cases, horrible in others.  I foresee a lot of places JDOM can be
> > useful in Cocoon - I've already got some folks interested in it for
> > certain applications.  Only time will tell...
> >
> > However, in response to your main point, JDOM will maintain complete
> > interoperability with DOM and SAX for as long as those APIs are heavily
> > used.
> >
> > -Brett
> >
> > >
> > > -scott
> > >
> > >
> > >                     Mike Engelhart
> > >                     <mengelhart@eart        To:     cocoon-dev@xml.apache.org
> > >                     htrip.com>              cc:     (bcc: Scott Boag/CAM/Lotus)
> > >                                             Subject:     Re: JDOM and Thank
You :)
> > >                     04/27/2000 01:15
> > >                     PM
> > >                     Please respond
> > >                     to cocoon-dev
> > >
> > >
> > >
> > > Brett D. McLaughlin wrote:
> > >
> > > > JDOM is an /alternative/ to DOM and SAX.  It provides a fast,
> > > > Java-optimized method of reading, writing, and manipulating XML.  (Btw,
> > > > the PowerPoint slides just went up on the website - check
> > > > download/docs.  PDF coming in an hour or so).  DOM is trying to be a
> > > > cross-platform, 100% accurate representation of an XML document.  We
> > > > don't believe that in most cases, Java developers need that.  THey want
> > > > an intuitive, usable means of accessing XML data.
> > > >
> > > > For example:
> > > >
> > > > <dom-code>
> > > > // This does *not* work, even though it is intuitive
> > > > String elementValue = element.getValue();
> > > > // This works (most of the time!)
> > > > String elementValue = element.getFirstChild().getValue();
> > > > </dom-code>
> > > awww yeah!!!
> > >
> > > Thanks for this!  I hated the W3C DOM API!!!! Apparently you and Jason did
> > > too :-)
> > >
> > > one question -have you tested it's interoperability with Cocoon 1.x (and/or
> > > 2.x)??
> > > Scenario:
> > > I'm about to rewrite some code to take data from a result set and want to
> > > put it directly into an XML fragment rather than an intermediate ArrayList.
> > > Can I use JDOM for this and hand a Node off to an XSP page for further
> > > processing using Xerces??  Please??? :-)
> > >
> > > thanks again...
> > >
> > > mike

Mime
View raw message