On Wed, 31 Oct 2001, James Strachan wrote:

> > 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" );
Agreed.

>
> Together with constructors to match...
>
> VariableContext variables = new SimpleVariableContext( "name", "Here's
> Johnny");
Hmm.. If you want this, then an addition as proposed below would also
work.
Maybe the method name 'setVariableValue' could be shortened to something
like 'put' :-) I think most people understand what a method with that name
would do.
And that method could return 'this', so you'd be able to write:

VariableContext context = new SimpleVariableContext().put( "name", "Here's
Johnny" ).put( "town", "Santa Clara" );


..

It would also be nice to have a way of replacing a variable reference with
a literal value in an xpath expression tree. Like:

XPath xpathArtist = new XPath("//a[@n=$name]");
xpathArtist.bindVariable( "name", "Here's Johnny" );

After that call, the xpath expression will effectively have changed to
"//a[@n=\"Here's Johnny\"]"

It would speed up the expression, but you cannot set the variable to
something else anymore. Yet sometimes that is exactly what you want.

- Erwin





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

Reply via email to