Re: Custom functions (Major re-write, please review)

Leigh,

As Michael Kay pointed out "User-defined functions get no context item, position, or size. That's true both for named global functions and inline functions." so you won't be able to use position()not last() in the default context of your function body.

The variables in scope for the function body include all variables representing the function parameters, as well as all variables that are in scope for the inline function expression.

Note: Function parameter names can mask variables that would otherwise be in scope for the function body.

Kind regards,

Nick Van den Bleeken
R&D Manager

Phone: +32 3 425 41 02
Office fax: +32 3 821 01 71
nick.van.den.bleeken@inventivegroup.com<mailto:nick.van.den.bleeken@inventivegroup.com>
www.inventivedesigners.com


[cid:image001.png@01CBF2F8.1DA19110][cid:image002.png@01CBF2F8.1DA19110][cid:image003.png@01CBF2F8.1DA19110]

On 14 Mar 2012, at 15:56, Leigh L. Klotz, Jr. wrote:

Nick Van den Bleeken writes:

So I think our custom functions also shouldn't do that. Now that we have variables you can work around this limitation.

Example:

<var name="context" value="."/>
<var name="context-pos" value="position()"/>
<var name="context-size" value="last()"/>
<function signature="my:f() as number" value="$context-pos = $context-size"/>


How does the scoping on this work?

Wouldn't you have to do this?

<function signature="my:f() as number" value="position() = last()"/>

Leigh.


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



________________________________

Inventive Designers' Email Disclaimer:
http://www.inventivedesigners.com/email-disclaimer

Received on Wednesday, 14 March 2012 15:05:34 UTC