sidewinderlabs / backplanejs

Other
12 stars 3 forks source link

Add support for custom functions when evaluating XPath with native DOM #53

Open backplane-import opened 13 years ago

backplane-import commented 13 years ago

Imported from backplanejs Google Code issue 53.

Reporter markbirbeck
Date 3 May 2010 8:26:22 PM UTC

In the expression:

a/b[func(d)]

the function func() needs to be a reference to a JavaScript function that is callable during evaluation (i.e., a non-standard function).

To implement this whilst still using a native DOM, the expression would need to be cracked open and the separate parts evaluated individually. In the example above we'd need to do the following:

  1. Get the node referred to by "d" and then retrieve the value; let's say it's '2'.
  2. Call the JavaScript function with the value returned from step 1, i.e., func( 2 ). Let's say this function returns 6.
  3. Insert the value returned from step 2 into the XPath expression and then evaluate the XPath expression.

This needs to be generic, since functions can appear anywhere in an XPath expression. For example:

func2(a/b[func(c/d)])

Note also that since XPath already comes with some built-in functions we can't simply check for anything of the form "abc()" -- we'll have to check for the extension functions by name.


Owner set to ----

Ticket status set to Accepted

Priority: Medium Type: Enhancement Added label: performance

backplane-import commented 13 years ago

Update by markbirbeck on 3 May 2010 8:29:43 PM UTC

Component: Logic

backplane-import commented 13 years ago

Update by markbirbeck on 3 May 2010 8:42:56 PM UTC

Removed label: performance