[jdom-interest] Element.getDocument() ?

Joerg joerg at freiheit.com
Thu Aug 31 10:56:10 PDT 2000

That's a good idea, you get two things at once. So, if you have no other
chance to get the owner document, you can get it like this.
Uh, but if you copy the root Element in another tree and maybe even in
another Document, you have to handle these cases. But you have to check the
isRootElement flag anyway somhow now. O.K. I will get deeper in the
implementation topics soon, I have a small time problem in the moment.
On the other hand, is there a chance to get a method version in the XPath
API, where you can give the Document explicitly to XPath? I made the
experience, that I have the owner Document anyway in the context where I
traverse the tree. When you have many XPath calls and you have always to
climb up the tree to get the Document, this would be a slight overhead.


Jason Hunter wrote:

> > And you have to think about, that even
> > when the Document is only stored in the root Element, it
> > at least increases the memory
> > footprint of all Elements (if this matters at all).
> >
> > Joerg
> There's not necessarily a memory bloat.  If you replace the boolean
> isRootElement with an Element parentDocument point^H^H^H^H^Hreference
> (and let a null value indicate you aren't the root), you've replaced 32
> bits with 32 bits on most systems.
> -jh-

<?xml version="1.0" standalone="no" encoding="ISO-8859-1"?>
    <bookmark> http://www.google.com </bookmark>
    <bookmark> http://www.gnu.org </bookmark>
    <bookmark> http://java.apache.org </bookmark>
    <bookmark> http://www.w3.org </bookmark>
    <bookmark> http://www-db.stanford.edu/lore </bookmark>
    <firstname> Jörg </firstname>
    <name> Kirchhof </name>
    <title> Dipl.-Ing. </title>
    <email> joerg at freiheit.com </email>
    <phone> +49-40-890584-14 </phone>
    <name> freiheit.com Technologieberatung GmbH </name>
    <address> Theodorstraße 42-90 </address>
    <zip> 22761 </zip>
    <city> Hamburg </city>
    <country> Germany </country>
    <phone> +49-40-890584-0 </phone>
    <fax> +49-40-890584-20 </fax>
    <www> http://www.freiheit.com </www>

More information about the jdom-interest mailing list