Hi Sebastian,

On this problem, a quick comment coming into my mind, since I faced a
comparable problem recently. Without changing XQUERY or BaseX, it is
possible to emulate overloading using the introspection module of BaseX.
But you need a map which keys and values are functions (not possible with
BaseX map module, but possible with XQUERY).

With such a map, keys are computed using the BaseX introspection module for
your prod functions, since values are computed using the BaseX
introspection module for your custom functions.

All calls are then concentrated through a dispatcher : something like

call($function,$argument) { if contains($MapOfFunctions, $function) then
map:get($MapOfFunctions,$function)(argument) else $function($argument) }.

I tested this trick very recently actually, to overload the xquery:eval
BaseX function. I named the resulting function evil_eval (a very dangerous
function) !

Hope this help

Cheers

Jean-Marc







2013/11/30 Wiemer, Sebastian <[email protected]>

>  Hi Christian,
>
> Hi Sebastian,
>
> thanks for your e-mail; I’m pleased to see you are still working with
> BaseX.
>
> And we still love BaseX :-)
> Thanks for keeping up the good work!
>
>  BTW: I unfortunately missed your and Alexanders presentation at the
> MarkUp Forum: are there any slides available?
>
>
>
> So just by dropping a file like „custom.xqm" in the restxq path, we can
> customize the system.
>
>
> …sounds like a nice idea.
>
> The drawback is that we can only use this for HTTPS requests from the
> client, but not from the server, because we use HTTPS. So we cannot use
> RESTXQ requests server side with http:send-request. (Or do we?)
>
>
> I guess I have no answer to that, as I haven’t actually come across
> this challenge yet. This might be completely off the track, but maybe
> it’s also a question of how Jetty is configured? Did you already check
> out the jetty.xml file and possible settings?
>
>
>  Yes, I checked jetty configuration (but I gave up), and it seems to me,
> that jetty.xml or web.xml might not be the right place for a solution after
> all.
>
>  What Florian and I probably are trying to accomplish here is a way to
> introduce aspect oriented or rule based
> programming to XQuery to decouple custom extensions from product code.
>
>  This is similar to imported modules in XSLT: If you import template
> rules, which are more specific,
> they will be applied first. Could this be applied to XQuery as well? (But
> in XSLT you would have to
> import the custom code and hence change your code. We can do that in
> XQuery as well, but it
> is not completely decoupled, is it?)
>
>  Florian and I came around with an idea, that does not use HTTP requests
> and maybe clarify
> our goal: how about introducing a „dispatch" annotation to XQuery?
>
>  Let’s assume we have a function „age“ that takes an age as integer and a
> name as string and prints a message.
> A customization would be to be more specific for teenagers. But we don’t
> want to change the code.
> the annotation „dispatch:declare“ declares a function to be potentially
> dispatched: if there is not a more specific
> function with a „dispatch:replace“ annotation, than that function is
> called.
> Maybe "dispatch:prepend" and "dispatch:append“ would be nice as well.
> Also it would come in very handy if the replacing function is allowed be
> updating or not updating.
>
>  product.xqm
> %dispatch:declare(age($age,$name))
>  declare function prod:age($age as xs:integer,$name as xs:string){
>   $name||" is "||$age||" years old."
> };
>
>  prod:age(14,'Emily’) = „Emily is 14 years old."
>
>  custom.xqm
>  %dispatch:replace(age(19>$age>13,$name))
> declare function custom:age($age as xs:integer,$name as xs:string){
>    $name||" is a "||$age||“ years old teenager."
> };
>
>
>  So a use of „prod:age“ would yield the result of „custom:age“:
>  *prod*:age(14,'Emily’) = „Emily is a 14 years old *teenager*.“
>
>
>  Comments on this idea are very appreciated.
>
>  Sebastian
>
>
> Christian
>
>
>
> _______________________________________________
> BaseX-Talk mailing list
> [email protected]
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
>
_______________________________________________
BaseX-Talk mailing list
[email protected]
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to