Ken, i'm afraid i've got another unsatisfactory answer for you...
In o:XML there's no null value, so you can't check if a variable is null.
And to reference a variable that is not defined is always an error.
This is somewhat inconsistent with the way the servlet engine sets
variables from the request parameters it receives.
To check if a servlet parameter exists you can access the
HttpServletRequest object directly through the variable $servlet:req, eg
<o:set value="$servlet:req.getParameter('param')"
xmlns:servlet="http://www.o-xml.com/servlet/"/>
<o:if test="not($value)">
... set default value
</o:if>
etc. It's a bit ugly though, and certainly not perfect.
I'm wanting to sort this issue out before the 1.0 release.
There are a couple of related problem areas that need ironing out:
1) It should be possible to run the same o:XML programs using the servlet,
ant task, command line or any other execution context (eg BSF).
2) It should be possible to pass parameters to these programs, and for
the programs to have default parameter values.
I think the solution is to declare the parameters directly under a special
program statement, much like procedure and function params are declared ->
<o:program standalone="yes|no">
<o:param name="param" select="default value"/>
...
</o:program>
Then the servlet context can set those params that have matching names in
the http request. It would make it as easy to use, but safer since you
always know which variables are in scope.
(standalone says whether the engine should produce a standalone XML
document or a simple XML fragment.)
regards,
/m
Martin Klang
http://www.o-xml.org - the object-oriented XML programming language
On Mon, 21 Jul 2003, Ken McCloskey wrote:
> Martin,
>
> I didn't see an answer to this in the documentation, though I may have
> missed it...
>
> How do I check whether a variable exists or not (== null)?
>
> I'm using the ObjectBox servlet and the $servlet variable to read the
> name/value pairs from the query string. But if the user calls a URL that
> doesn't have all the query string variables I'm looking for, I want to use
> defaults.
>
> Ken
>
> _________________________________________________________________
> Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> http://join.msn.com/?page=features/junkmail
>
> _______________________________________________
> o-xml mailing list
> o-xml-zRfLyl9bSvv/LJnD5RR8eeqUGfbH9hYC@xxxxxxxxxxxxxxxx
> http://lists.pingdynasty.com/mailman/listinfo/o-xml
>
|