Project

Profile

Help

Should xsl:assert cause an error if fn:transform is run with 'enable-assertions' : true()?

Added by Martin Honnen over 4 years ago

I can't seem to find a way to get fn:transform to raise an error by an xsl:assert, even if I set the option 'enable-assertions' : true(); a simple test case run with XQuery and using Saxon 9.9.1.6 HE from the command line gives no error:

transform(map {
  'stylesheet-node' :
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:mf="http://example.com/mf"
            exclude-result-prefixes="#all">
            
            <xsl:param name="DEBUG" as="xs:boolean" select="true()" 
                static="yes" required="no"/>
            
            <xsl:param name="date" as="xs:date" select="xs:date('2030-01-01')"/>
            
            <xsl:function name="mf:days-elapsed" as="xs:decimal" visibility="public">
                <xsl:param name="since" as="xs:date"/>
                <xsl:assert use-when="$DEBUG" test="$since lt current-date()"/>
                <xsl:sequence select="(current-date() - $since) div xs:dayTimeDuration('P1D')"/>
            </xsl:function>
            
            <xsl:template name="xsl:initial-template">
                <xsl:sequence select="mf:days-elapsed($date)"/>
            </xsl:template>
            
        </xsl:stylesheet>,
    'enable-assertions' : true()
  }
)?output

but rather outputs <?xml version="1.0" encoding="UTF-8"?>-3676.


Replies (1)

RE: Should xsl:assert cause an error if fn:transform is run with 'enable-assertions' : true()? - Added by Martin Honnen over 4 years ago

A further investigation using XSLT instead of XQuery to call fn:transform shows that the assert raises XTMM9001 if -ea:on is set on the command line for Saxon. The value of the option enable-assertions on the transform call itself doesn't seem to be taken into account.

    (1-1/1)

    Please register to reply