|
Hi Christian,
Hi Sebastian,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?
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
|
_______________________________________________ BaseX-Talk mailing list [email protected] https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

