[jdom-interest] Element Reference from Attribute

bob mcwhirter bob at werken.com
Fri Nov 17 06:56:58 PST 2000


> > We should have a way to get the Element reference from the Attribute.  I was
> > trying to design DOM Level2 feature of Events incorporating in JDOM this
> > requires all possible navigation capabilities from any node to root node.
> > Has any one thought of implementing DOM Level2 for JDOM?  If we think DOM
> > Level2 we must provide a way to get the total path to the root from any node
> > including PI's, Attributes and even from CDATA sections.  Plz put forward
> > your thoughts on this.
> 
> I guess I missed something early in this discussion, so this is probably a
> dumb question. At what point in your code do you have a reference to 
> an Attribute that you didn't get via
> 
> 	Attribute a = e.getAttribute(key);
> 
> That is, how is it that one can be navigating from an Attribute with no
> knowledge of the Element with said Attribute?

Using my XPath library, for one.

	XPath xpath = new XPath("/foo/bar/baz/@goober");

	List results = xpath.applyTo( myDoc );

You're now holding a list of Attributes named 'goober', with no
convenient way to find the parent.  (Which also means I can't implement
easily the XPath of "/foo/bar/baz/@goober/..", which would automagically
return the parents of all 'goober' attributes).

	-bob
	(http://code.werken.com/)




More information about the jdom-interest mailing list