Adding core XPath functions

2 views
Skip to first unread message

Mark Birbeck

unread,
Nov 1, 2009, 7:18:02 AM11/1/09
to ubiquity-...@googlegroups.com
Hello all,

As you'll know, the technique that we've been using to add core XPath
functions to the library is to place them directly into the AJAXSLT
object, like this:


FunctionCallExpr.prototype.xpathfunctions["hmac"] = function(ctx) {
...
};

There are a number of problems with this:

1. It hard-codes the dependency on the underlying XPath library, by
not having an intermediate 'registration' step.

2. The first few lines of such extension functions invariably unpack
'ctx' in order to get the parameters ready for use by JavaScript, and
the last line then usually repackages the result for AJAXSLT; this
common code should really be factored out.

3. The requirement on this common code means that authors can't create
'pure' JavaScript functions, but have to get involved in interfacing
to the AJAXSLT library.

As a first step towards a more flexible model of component
registration (custom widgets, XPath functions, and so on), we've added
a method that gives us function registration. The technique to use is
described on the following wiki page:

<http://code.google.com/p/ubiquity-xforms/wiki/HowToAddingAnXpathFunction>

As you can imagine, the definition of the object passed as a parameter
will change, since we want it to support all sorts of different
extension types -- but we want to stick with the agile approach of
only designing as much as we need at any given time, so the current
object is very simple (naive would be more precise).

But I'm making everyone aware of this now, in case anyone is 'in the
area' and wants to do any refactoring, or is going to embark on adding
any new functions.

Note that there is a lot of crossover with this and Bryan's work on
allowing inline JavaScript functions to be used in XPath, and we'll
definitely by looking to merge the two things together. (In
particular, the marshalling code needs to be a common function.)

Regards,

Mark

--
Mark Birbeck, webBackplane

mark.b...@webBackplane.com

http://webBackplane.com/mark-birbeck

webBackplane is a trading name of Backplane Ltd. (company number
05972288, registered office: 2nd Floor, 69/85 Tabernacle Street,
London, EC2A 4RR)

Reply all
Reply to author
Forward
0 new messages