> VariableContext variables = new SimpleVariableContext();
> context.setVariableValue( "", "name", "Here's Johnny" );

actually the first parameter should probably be null (after checking the
javadoc comments) like this...

context.setVariableValue( null, "name", "Here's Johnny" );

It'd be nice to add a helper method for common variable access where a
namespace URI is not required for a variable name like this...

context.setVariableValue( "name", "Here's Johnny" );

Together with constructors to match...

VariableContext variables = new SimpleVariableContext( "name", "Here's
Johnny");


James

>
>
> 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

Reply via email to