Delayed function nodes now wrapped in f:ref node
This primarily allows us to type check, but will also may it easy/performant to query more complicated structures.master
parent
eb66c838c6
commit
1c01e765a7
|
@ -32,14 +32,14 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
|
||||
<apply-templates select="$fnref" mode="f:apply" />
|
||||
</function>
|
||||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
|
||||
<apply-templates select="$fnref" mode="f:apply">
|
||||
|
@ -49,7 +49,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
|
||||
|
@ -61,7 +61,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -75,7 +75,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -91,7 +91,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -109,7 +109,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -129,7 +129,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -151,7 +151,7 @@
|
|||
|
||||
|
||||
<function name="f:apply">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -201,7 +201,7 @@
|
|||
determined, -1 is returned.
|
||||
-->
|
||||
<function name="f:arity" as="xs:decimal">
|
||||
<param name="fnref" as="element()" />
|
||||
<param name="fnref" as="element(f:ref)" />
|
||||
|
||||
<sequence select="if ( $fnref/@arity ) then
|
||||
$fnref/@arity
|
||||
|
|
|
@ -157,11 +157,15 @@
|
|||
<namespace name="{$ns-prefix}"
|
||||
select="$ns" />
|
||||
|
||||
<element name="{$local-name}"
|
||||
namespace="{$ns}">
|
||||
<f:ref>
|
||||
<attribute name="arity"
|
||||
select="count( $fnref/xsl:param )" />
|
||||
</element>
|
||||
|
||||
<!-- represents the function being referenced -->
|
||||
<element name="{$local-name}"
|
||||
namespace="{$ns}">
|
||||
</element>
|
||||
</f:ref>
|
||||
</out:function>
|
||||
</function>
|
||||
|
||||
|
@ -184,7 +188,7 @@
|
|||
select="$defn/xsl:param" />
|
||||
|
||||
<out:template mode="f:apply"
|
||||
match="{$name-resolv}"
|
||||
match="f:ref[ {$name-resolv} ]"
|
||||
priority="5">
|
||||
<namespace name="{$ns-prefix}"
|
||||
select="$ns" />
|
||||
|
|
|
@ -28,20 +28,20 @@
|
|||
<import href="../src/apply.xsl" />
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn0">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn0 ]">
|
||||
<!-- return something to show that we were called properly -->
|
||||
<sequence select="0" />
|
||||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn1">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn1 ]">
|
||||
<param name="arg1" />
|
||||
|
||||
<sequence select="string($arg1)" />
|
||||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn2">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn2 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn3">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn3 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -58,7 +58,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn4">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn4 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -68,7 +68,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn5">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn5 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -80,7 +80,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn6">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn6 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -93,7 +93,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn7">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn7 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
@ -107,7 +107,7 @@
|
|||
</template>
|
||||
|
||||
|
||||
<template mode="f:apply" match="foo:fn8">
|
||||
<template mode="f:apply" match="f:ref[ foo:fn8 ]">
|
||||
<param name="arg1" />
|
||||
<param name="arg2" />
|
||||
<param name="arg3" />
|
||||
|
|
|
@ -33,7 +33,9 @@
|
|||
|
||||
<call function="f:apply">
|
||||
<param name="fnref">
|
||||
<foo:fn1 />
|
||||
<f:ref>
|
||||
<foo:fn1 />
|
||||
</f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="$arg" />
|
||||
</call>
|
||||
|
@ -48,7 +50,9 @@
|
|||
<scenario label="applying">
|
||||
<scenario label="nullary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn0 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn0 /></f:ref>
|
||||
</param>
|
||||
</call>
|
||||
|
||||
<expect label="passes each argument"
|
||||
|
@ -58,7 +62,9 @@
|
|||
|
||||
<scenario label="unary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn1 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn1 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
</call>
|
||||
|
||||
|
@ -69,7 +75,9 @@
|
|||
|
||||
<scenario label="binary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn2 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn2 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
</call>
|
||||
|
@ -81,7 +89,9 @@
|
|||
|
||||
<scenario label="ternary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn3 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn3 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -94,7 +104,9 @@
|
|||
|
||||
<scenario label="4-ary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn4 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn4 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -108,7 +120,9 @@
|
|||
|
||||
<scenario label="5-ary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn5 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn5 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -123,7 +137,9 @@
|
|||
|
||||
<scenario label="6-ary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn6 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn6 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -139,7 +155,9 @@
|
|||
|
||||
<scenario label="7-ary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn7 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn7 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -156,7 +174,9 @@
|
|||
|
||||
<scenario label="8-ary function">
|
||||
<call function="f:apply">
|
||||
<param name="fnref"><foo:fn8 /></param>
|
||||
<param name="fnref">
|
||||
<f:ref><foo:fn8 /></f:ref>
|
||||
</param>
|
||||
<param name="arg1" select="1" />
|
||||
<param name="arg2" select="2" />
|
||||
<param name="arg3" select="3" />
|
||||
|
@ -182,7 +202,9 @@
|
|||
<!-- test our format directly; do not rely on the
|
||||
apply-gen code -->
|
||||
<variable name="fnref">
|
||||
<foo:bar arity="{$test-arity}" />
|
||||
<f:ref arity="{$test-arity}">
|
||||
<foo:bar />
|
||||
</f:ref>
|
||||
</variable>
|
||||
|
||||
<call function="f:arity">
|
||||
|
@ -197,7 +219,7 @@
|
|||
|
||||
<scenario label="given a function reference with no defined arity">
|
||||
<variable name="fnref">
|
||||
<foo:bar />
|
||||
<f:ref><foo:bar /></f:ref>
|
||||
</variable>
|
||||
|
||||
<call function="f:arity">
|
||||
|
|
|
@ -49,13 +49,15 @@
|
|||
|
||||
<!-- the generated node is simply the same name and namespace as
|
||||
the function -->
|
||||
<expect label="generated function produces function node"
|
||||
test="exists( xsl:stylesheet/xsl:function/foo:bar )" />
|
||||
<expect label="generated function produces function reference
|
||||
node"
|
||||
test="exists( xsl:stylesheet/xsl:function/f:ref/foo:bar )" />
|
||||
|
||||
|
||||
<!-- more detailed tests below -->
|
||||
<expect label="generates application template"
|
||||
test="xsl:stylesheet/xsl:template/@match = 'foo:bar'" />
|
||||
test="xsl:stylesheet/xsl:template/@match
|
||||
= 'f:ref[ foo:bar ]'" />
|
||||
|
||||
<expect label="generated template has mode f:apply"
|
||||
test="xsl:stylesheet/xsl:template/@mode = 'f:apply'" />
|
||||
|
|
Loading…
Reference in New Issue