Subject: Re: [xsl] [FXSL] Using document('') to get the high-level function (+ a little bug?) From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Sat, 24 Jun 2006 06:54:48 -0700 |
There is no mailing list on the SF.net project page for FXSL, but I think my question is on topic here (Dimitre, could you please let me know if there is a more appropriate place to discuss FXSL?).
FXSL Help Help Open Discussion
I agree with Colin and would be glad to add you as a developer to the FXSL project -- please, let me know.
I noted that FXSL for XSLT 2.0 still uses in its test scripts the following construct to pass the high-level function to the FXSL templates:
<myAdd:myAdd/> <xsl:template match="/"> <xsl:variable name="vFun" select="document('')/*/myAdd:*[1]"/> <xsl:call-template name="zipWith"> <xsl:with-param name="pFun" select="$vFun"/> ...
So it requires to access to the XML rpresentation of the script. Is there any reason (other than historical) to not use something like the following, which IMHO seems more appropriate (at least in large scripts)?
<xsl:template match="/"> <xsl:variable name="vFun" as="element()"> <myAdd:myAdd/> </xsl:variable> <xsl:call-template name="zipWith"> <xsl:with-param name="pFun" select="$vFun"/> ...
What is more, do not use this template at all -- there is an xsl:function named f:zipWith and it should be used with FXSL2.
The legacy templates are included in FXSL2 to ensure that old FXSL 1.x code is still supported.
In fact in the test of f:zipWith(), an even better way is used to pass the function-parameter (see the file testFunc-zipWith.xsl):
Here one doesn't manually provide/code a reference to a function that adds its two arguments -- FXSL provides higher-order function wrappers as f:add() above, which evaluate to the necessary reference. Also, these wrappers are identically named as the referenced original F & O function/operator (if we disregard the namespace), so in order to pass the "+" operator as a parameter one simply writes "f:add()"
This will be presented and discussed in detail in my presentation at the Extreme Markup Languages 2006 conference in August.
BTW, the zipWith template call itself recursively, passing the literal default value 'el' for the pElName parameter, instead of the actual value of this parameter, $pElName. I guess it is a bug?
<xsl:call-template name="zipWith"> ... <xsl:with-param name="pElName" select="'el' (: not $pElName ? :)"/> </xsl:call-template>
Yes, this is a legacy of the FXSL 1.x code, which as I mentioned has been just copied into FXSL 2.0, but everyone is encouraged to use the new code, based on xsl:function. In the implementation of f:zipWith() the two parameter-lists are simply sequences, so there's no need to represent their items as elements and there is no parameter for the element name.
-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] RE : Re: [xsl] [FXSL] Using d, Florent Georges | Thread | Re: [xsl] [FXSL] Using document(''), Florent Georges |
[xsl] RE : Re: [xsl] [FXSL] Using d, Florent Georges | Date | RE: [xsl] Removing elements based o, Michael Kay |
Month |