For some reason, I've received this thread all out of order.

Problem #1:

        You're doing string concatenation, and attempting
        to parse the bogus xpath of "//a[@n='Here's Johnny']"
        
        It's bogus because you have unbalanced quotes.

Problem #2:

        As I read it (which could be 100% wrong), there is
        no provision for escaping quotes of either style.
        " and ' are *not* caught by the xpath
        parser.  They are not defined for the XPath lexical
        model.

        You *can* use them, when passing xpaths in from
        another XML document, but in that case, they get
        unescaped by the *XML* parser before being handed
        to the XPath engine.  ie. xslt:

        <value-of select="foo/bar[@name=&quot;cheese&quot;]"/>

Problem #3:

        Directly related to #2, you cannot use backlash
        escapes for strings in the xpath engine.  I could
        make it work, but it'd be non-conformant, and when
        constructing from literal strings in java, would
        look like ass, since you'd have to use 3 slashes.

        String expr = "foo/bar[@name=\\\"cheese\\\"]"

Anyone offer a better solution?

        -bob




On Wed, 31 Oct 2001, Jason Long wrote:

> I have been working on an application that uses both jdom and jaxen.
> 
> Here is and example of my problem?
> 
> String str = "Johnny's Dinner";
> XPath xpathArtist = new XPath("//a[@n='" + str + "']");
> 
> I read somewhere that replacing ' with "'" or " with '"'.
> 
> Is this the best way to do this?
> Is there support built into jaxen to clean up string prior to being used in
> XPath?
> 
> Best Regards,
> 
> Jason Long
> JML Internet Enterprises - www.jmlie.com
> BS Physics, MS Chemical Engineering
> 
> 
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> 


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to