Closed GoogleCodeExporter closed 9 years ago
[deleted comment]
[deleted comment]
To support good values, we could change the for-loop to be:
for(var p in params) {
var v;
var pp = params[p];
switch(pp) {
case 'true':
v = new BooleanValue(true);
break;
case 'false':
v = new BooleanValue(false);
break;
default:
if(/^[0-9]+$/.test(pp))
v = new NumberValue(parseInt(pp));
else
v = new StringValue(pp);
break;
}
c.setVariable(p, v);
}
Original comment by rst...@gmail.com
on 23 Oct 2007 at 12:14
I like the idea of this patch, but I'm a bit worried about it, because it uses
"for
(var p in params)", which may not work if Object.prototype has been modified.
We
could workaround using .hasOwnProperty, but AJAXSLT is meant for browsers with
very
limited JS support, so we can't be sure we'll be able to use .hasOwnProperty.
[IMO,
there's no good implementation of an associative array with key iterators
available
to us.]
In the latest checked in version of xpath.js, ExprContext.setVariable now more
naturally supports passing in native JS values; it will convert them into XPath
values on-the-fly.
Instead of creating a new Object(), filling it up with values, and passing it to
xsltProcess, you can/should create a new ExprContext and call setVariable on it
for
all the parameters you want to pass in. Then your can call xsltProcessContext
with
the context you created. That should be safer in general.
Original comment by DanFabul...@gmail.com
on 7 Nov 2007 at 4:47
Original issue reported on code.google.com by
rst...@gmail.com
on 23 Oct 2007 at 12:01