[jdom-interest] Element Reference from Attribute

bob mcwhirter bob at werken.com
Fri Nov 17 09:54:11 PST 2000


> Ok. That is pretty straightforward. But then again, you did ask for the
> "goober" Attributes, not the Elements with "goober"s :-)

You're right, but someone might want to do that.  Sure, there's a
better XPath for it, but it's still legal to do as I described.

> Aahh... Here you do want the Elements with "goober"s. When you say you 
> cannot implement it, you are saying you can't implement it on top of 
> XPath("/foo/bar/baz/@goober") - ie. get the attributes and then traverse - but 
> you could implement it directly since you can keep both the Element and 
> Attribute references handy while traversing... yes? namely,

I'm saying that I can't easily (though, it's not impossible) implement
the perfectly legal XPath of '/foo/bar/baz/@goober/..'  Sure, it's
equivelent to '/foo/bar/baz[@goober]', but no telling what someone
else might want to do.

> 	Element e = ...
> 	Attribute a = e.getAttribute("goober");
> 	if (a != null )
> 		addToList(e);

Right, which is the 2nd case of '/foo/bar/baz[@goober]', but we
still haven't figured out the 1st case.

> The question still reduces to "do we ever have only an Attribute reference
> and want the Element?" 

I still stand by my use-case that folks may use an XPath to extract
some Attributes, and then wish to find the owning Element.

	-bob




More information about the jdom-interest mailing list