|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] objects in xquery?Michael Kay mike at saxonica.comMon Jun 11 11:34:04 PDT 2007
If eXist doesn't provide any way of setting the value of an external variable then you might have to do it this way. It seems a shame however to use extensions when it could be done without. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: bryan rasmussen [mailto:http://x-query.com/mailman/listinfo/talk] > Sent: 11 June 2007 10:12 > To: Michael Kay > Cc: http://x-query.com/mailman/listinfo/talk > Subject: Re: objects in xquery? > > Hmm, the calling application is Exist however, and the file > is itself an XQL file that is interpreted by Exist. > > > Wouldn't it be more like inside of my query I have: > > declare function my:xmlobject() as element(){ return > <defaultparams> <param name="path">demos</param> <param > name="page">page1.xml</param> </defaultparams> > > }; > > > And then I need to call that function from my parameter > getting function, check if the parameter exists in the query > string, if not get it from my:xmlobject? > > Does this seem reasonable, it seems reasonable to me when i > enunciate it. > > Cheers, > Bryan Rasmussen > On 6/11/07, Michael Kay <http://x-query.com/mailman/listinfo/talk> wrote: > > > > 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: http://x-query.com/mailman/listinfo/talk > > > [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of bryan rasmussen > > > Sent: 11 June 2007 08:13 > > > To: http://x-query.com/mailman/listinfo/talk > > > Subject: 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 > > > _______________________________________________ > > > http://x-query.com/mailman/listinfo/talk > > > http://x-query.com/mailman/listinfo/talk > > > >
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






