[jdom-interest] Element Reference from Attribute

bob mcwhirter bob at werken.com
Sat Nov 18 05:04:07 PST 2000


> So, I'd say (1) leave it alone. If people use el.addAttribute(a) then they have to know
> it is shallow. Most of the time that is what you want. 

Though, if you can do thisElem.addAttribute( attr ) and thatElem.addAttribute( attr ),
and JDOM provides a getParent(), then it'll be wrong 50% of the time.  Attributes
shouldn't be immutable.  But, they can only have 1 parent.  Congruent with how
Element works now.  (Though, you have to manually remove the Element from one
parent before adding to another, which is fine by me, as it makes it explicit
what's going on.)

> For a "transformer" implementation (say XSLT kind of thing) does the Document
> get changed in place or is a new one created? The former would obviously
> be hazardous with shared references to objects that could be transformed...

The spec reads as though you have an input-tree and an output-tree.  They
aren't the same tree. A single item in the input-tree might endup in the
output tree multiple times, one time, or no times, in various orderings.

So, that's not a problem.

> I assume Builders don't figure out how to share (ie. intern) objects... although
> maybe a "read-only" document could make use of such a thing?

JDOM itself, though, does share/intern Namespace objects, which is another
PITA, since that prevents tracking parentage there.

	-bob




More information about the jdom-interest mailing list