Project

Profile

Help

Support #6518

closed

Different handling of "xs:boolean" result from function and local "false()"?

Added by Uwe Lagler 3 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2024-08-25
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Java

Description

I am not sure what causes the following problem: item types of a function's params are validated even if the function is not invoked. But this only happens if the conditional test is using the xs:boolean result of a function.

Situation A) The function "my:process()" will cause the error "XPTY0004 The required item type of the first argument of my:handle-map() is map(xs:string, item())", but why is the function my:handle-map() invoked at all?

<xsl:function name="my:is-map" visibility="public" as="xs:boolean">
    <xsl:param name="item"/>
    <xsl:sequence select="$item instance of map(xs:string, item())"/>
</xsl:function>

<xsl:function name="my:handle-map" visibility="public">
    <xsl:param name="map" as="map(xs:string, item())"/>
    <map>
        <size><xsl:value-of select="map:size($map)"/></size>
    </map>
</xsl:function>

<xsl:function name="my:do-something" visibility="public">
    <xsl:param name="item"/>
    <no-map>Do something with other value than map.</no-map>
</xsl:function>

<xsl:function name="my:process" visibility="public">
    <xsl:sequence select="

        let $test1 := map{'a': 'b'},
            $test2 := true(),
            $value := $test2
        return

            if(my:is-map($value)) then(
                my:handle-map($value)
            ) else(
                my:do-something($value)
            )

    "/>
</xsl:function>

Situation B) The same conditional test is working as expected if it is done directly (without a function call), the function my:handle-map() is not invoked and no error is thrown:

<xsl:function name="my:process" visibility="public">
    <xsl:sequence select="

        let $test1 := map{'a': 'b'},
            $test2 := true(),
            $value := $test2
        return

            if($value instance of map(xs:string, item())) then(
                my:handle-map($value)
            ) else(
                my:do-something($value)
            )

    "/>
</xsl:function>

Is there a difference between "false()" and the xs:boolean result from a function? I could be wrong but I would expect the xs:boolean result of a function can be used as it is.


Files

test.xsl (2.05 KB) test.xsl Uwe Lagler, 2024-08-25 16:23

Please register to edit this issue

Also available in: Atom PDF