The NullPointerException you mailed me was actually due to the parsing of
the XPath expression, it was in the saxpath code.

So its this line thats failing...

>     XPath xpathArtist = new XPath("CD_Library/artist[@name=$artist]");

How recent a version of Jaxen & saxpath have you got?

James
----- Original Message -----
From: "Jason Long" <[EMAIL PROTECTED]>
To: "Jaxen-Interest" <[EMAIL PROTECTED]>
Sent: Wednesday, October 31, 2001 9:08 PM
Subject: RE: [Jaxen] Escaping ' and " in xpath strings


>     // This is the code that I was using and works except for when artist
> contains '
>     XPath xpathArtist = new XPath("CD_Library/artist[@name='" + artist +
> "']");
>     List listArtist = xpathArtist.selectNodes(doc);
>
>     // This is was my attempt to use your suggestion.
>     // I tried using null, "", and even a made up string, but I get a
>     // NullPointerException in all cases
>     SimpleVariableContext variables = new SimpleVariableContext();
>     variables.setVariableValue(null, "artist", artist );
>     XPath xpathArtist = new XPath("CD_Library/artist[@name=$artist]");
>     xpathArtist.setVariableContext(variables);
>     List listArtist = xpathArtist.selectNodes(doc);
>
> Do you see some problem with the way I am using the VariableContext?
>
> Best Regards,
>
> Jason Long
> JML Internet Enterprises - www.jmlie.com
> BS Physics, MS Chemical Engineering
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of James
> Strachan
> Sent: Wednesday, October 31, 2001 2:20 PM
> To: [EMAIL PROTECTED]; Jaxen-Interest
> Subject: Re: [Jaxen] Escaping ' and " in xpath strings
>
>
> VariableContext variables = new SimpleVariableContext();
> context.setVariableValue( "", "name", "Here's Johnny" );
>
>
> XPath xpathArtist = new XPath("//a[@n=$name]");
> xpathArtist.setVariableContext( variables );
>
> ...
>
> James
> ----- Original Message -----
> From: "Jason Long" <[EMAIL PROTECTED]>
> To: "Jaxen-Interest" <[EMAIL PROTECTED]>
> Sent: Wednesday, October 31, 2001 8:15 PM
> Subject: [Jaxen] Escaping ' and " in xpath strings
>
>
> >
> > Could you please give me an example of how to do I do this using jaxen?
> > I have used this with XSL, but never from java code.
> >
>
> --------------------------------------------------------------------------
> --
> > --
> > James wrote:
> >
> > You could use XPath variables to get around this. Then your XPath
> expression
> > could be
> >
> > //a[@n=$str]
> >
> > Then you could create a VariableContext and put any old string
containing
> > any number of quote characters.
> >
> > James
> > ----- Original Message -----
> > From: "Jason Long" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, October 31, 2001 7:13 PM
> > Subject: [Jaxen] Escaping ' and " in xpath strings
> >
> >
> > > 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
> >
> >
> > _________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> >
> >
> > _______________________________________________
> > Jaxen-interest mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> _______________________________________________
> 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


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Reply via email to