[jdom-interest] new to jdom .. and many questions

Azrael azrael at azrael-uk.f2s.com
Tue Aug 27 17:55:48 PDT 2002


Just joined the list, and thought I'd jump in at the deepend.

I'm working on a project for my MSc to write up an XML compression
algorithm theorised by my supervisor... and I did so without too much
attention to actual manipulation of the XML file .. and instead wrote a
simple xml interface providing the methods I needed to have access to.
Now theoretically (from a lot of manual testing) the algorithm works ..
however to get it to work practically I have to attach my xml interface
onto something real.. which as I have some time left over.. I have 
decided to attempt.
JDOM looks to be almost perfect.. and I admit I haven't spent too much
time looking at it in depth.. but I am sure to be having quite a few
questions on how to do things in order to have jdom functionality under
the hood of my xml classes.

Ok.. so here's my first question:

assuming I have a 'pointer' to the current element:
org.jdom.Element currentElement = <whatever>

and I move up and down the structure with getChild() and getParent()

I would like to implement a method that does:

public boolean hasMoreElements()

basically how it would work, is that if this element is the very last 
element in the whole dom tree, it returns false, otherwise true.
I'm not totally sure how to check this.... it isn't sufficient to have 
no children.. the parent also needs to have no more children.. and the 
parent needs to be the last child ot its parent.. and so on..
am I thinking along the wrong lines? Can anyone suggest a way in which I 
can do this within jdom?

Closely associated with this problem, is my next question, I want a 
method that does:

public Element getNextElement()

this would not return the first child of the currentElement, but instead 
will return currentElements parents _next_ child.
And if currentElement is the final child of its parent, return the first 
child of my parents first child.
basically navigating the dom tree in a breadth first way.

             1
          2  3  4
        5  6  7  8
      9  10 11 12 12

Again, can anyone suggest the best way of doing this?

-- 
                  Azrael

             ("\''/").___..--'''"-._
             `0_ O  )   `-.  (     ).`-.__.`)
             (_Y_.)'  ._   )  `._ `. ``-..-'
           _..`--'_..-_/  /--'_.' .'
          ((i).-''  ((i).'  (((.-'

Of all God's creatures there is only one that cannot be made the slave
of the lash. That one is the cat. If man could be crossed with a cat it
would improve man, but it would deteriorate the cat.

ICQ#52944566





More information about the jdom-interest mailing list