[xquery-talk] objects in xquery?

Michael Kay mike at saxonica.com
Mon Jun 11 10:49:16 PDT 2007


In the calling application, construct an XML document that holds the
parameter values. Pass this XML document to the query as an external
variable, and access the values of individual parameters using path
expressions.

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: talk-bounces at x-query.com 
> [mailto:talk-bounces at x-query.com] On Behalf Of bryan rasmussen
> Sent: 11 June 2007 08:13
> To: talk at x-query.com
> Subject: [xquery-talk] objects in xquery?
> 
> Hi,
> 
> I have a situation where I want to get a certain number of 
> parameters, and if the parameters do not exist or are empty 
> to use a default string value instead, something like:
> 
> 
> 
>  declare function test:mappath() as xs:string{
> 
>  if(request:get-parameter("path", ()) !='')  then
>    request:get-parameter("path", ())
>  else
>    "demos"
> 
> 
>  };
> 
> as a general rule though in other server side languages what 
> I like to do when doing this kind of thing is to compose an 
> object that holds the values, some example pseudocode:
> 
> x as object();
> x{
> path="demos";
> page="page1.xml";
> 
> 
> 
> }
> 
> then a function (have used the same structure as the xquery 
> function above but obviously syntactically is not xquery)
> 
> getparam(param){
>  if(request:get-parameter(param, ()) !='')  then
>    request:get-parameter(param, ())
>  else
>    x[param]
> 
> 
>  }
> then I can just do
> path = getparam("path")
> and so forth.
> 
> 
> So I would like to know if this kind of thing is possible in Xquery.
> Perhaps what to do is to build a function that returns XML 
> and then use xpath to get at the value in that function?
> If possible it would nice if someone had an example of the 
> way to do the thing above?
> 
> Thanks,
> Bryan Rasmussen
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk



More information about the talk mailing list