I have a Java AST, and I'm trying to find a variable inside it through XPath.
Suppose a variable is called "foobar", I could use
//VariableDeclarator/VariableDeclaratorId[@Image='foobar']
but what if I don’t know the text "foobar", but I want to read it from another element
//VariableDeclarator/VariableDeclaratorId[@Image=//SynchronizedStatement/Expression/PrimaryExpression/PrimaryPrefix/Name]
The "name" node contains the information "foobar" in @Image, but PrimaryPrefix/Name[@Image]does not work.
How do I rewrite a condition //SynchronizedStatement/Expression/PrimaryExpression/PrimaryPrefix/Namethat it matches @Image='foobar'?
thank
source
share