String interpreted correct?

From: Petterson Mikael (mikael.petterson_at_era.ericsson.se)
Date: 01/30/04


Date: Fri, 30 Jan 2004 11:30:37 +0100

How can I add a java String variable to an XPath expression?

Example:

    String parent = "John";
    String query =
"//Foundation.Core.Class[Foundation.Core.ModelElement.name='"+parent+"']/Foundation.Core.Gene
ralizableElement.specialization"

But it gives:

//Foundation.Core.Class[Foundation.Core.ModelElement.name='John']/Foundation.Core.Gene
ralizableElement.specialization"

which will not be interpreted correct by XPath.

   How can I make sure that query is interpreted as:

  
//Foundation.Core.Class[Foundation.Core.ModelElement.name="John"]/Foundation.Core.Gene
ralizableElement.specialization"

BR

//Mikael