<xsl:if test="$f:window-size mod 2 eq 0 or $f:window-size lt 3">
<xsl:message terminate="yes" select="concat('Invalid window size: ', $f:window-size, '; window size must be odd integer greater than 3')" />
</xsl:if>
<pseudo-map xmlns:djb="http://www.obdurodon.org"
xmlns:f="http://www.obdurodon.org/function-variables">map{"column-number":19,"line-number":126,"module":"file:/Users/djb/repos/plot/lib/plot-lib.xsl","code":Q{http://www.w3.org/2005/xqt-errors}XTMM9000,"value":(),"description":"Processing terminated by xsl:message at line 126 in plot-lib.xsl. Found while atomizing the result of a call to djb:get-weights-scale#3"}</pseudo-map>
Yes, you can test <xsl:message terminate="yes">. I added some description to https://github.com/xspec/xspec/wiki/Writing-Scenarios#testing-dynamic-errors . Hope it helps.----- Original message -----From: David Birnbaum <djb...@gmail.com>To: XSpec <xspec...@googlegroups.com>Subject: Trapping <xsl:message>?Date: Sunday, June 28, 2020 05:03
Is it possible for a test to trap <xsl:message terminate="yes">? I am able to trap error(), so the functionality is available in a different way, but I do not find any documentation at https://github.com/xspec/xspec/wiki/Writing-Scenarios#testing-dynamic-errors about how to trap an <xsl:message> that is supposed to terminate a transformation.
--You received this message because you are subscribed to the Google Groups "XSpec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xspec...@googlegroups.com.
Running Tests...
Testing with SAXON EE 10.0
To view this discussion on the web visit https://groups.google.com/d/msgid/xspec-users/fa78ec20-a3e2-435a-ad04-b08af826a5f8o%40googlegroups.com.
(base) koala-4:lib djb$ cat message-test.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:djb="http://www.obdurodon.org"
xmlns:f="http://www.obdurodon.org/function-variables"
xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math"
version="3.0">
<xsl:function name="djb:get-weights-scale" as="xs:double+">
<xsl:param name="f:window-size" as="xs:integer"/>
<xsl:if test="$f:window-size mod 2 eq 0 or $f:window-size lt 3">
<xsl:message terminate="yes"
select=
"
normalize-space(concat('Invalid window size: ',
$f:window-size, '; window size must be odd integer greater than
3'))"
/>
</xsl:if>
<xsl:sequence>1</xsl:sequence>
</xsl:function>
</xsl:stylesheet>
(base) koala-4:lib djb$ cat message-test.xspec
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec" xmlns:djb="http://www.obdurodon.org"
xmlns:f="http://www.obdurodon.org/function-variables" stylesheet="message-test.xsl">
<x:scenario label="Scenario for testing function get-weights-scale" catch="yes">
<x:call function="djb:get-weights-scale">
<x:param name="f:window-size" select="4"/>
</x:call>
<x:expect label="err:value"
test="$x:result?err?value/text()">Invalid window size: 4; window size must be odd integer greater than 3</x:expect>
</x:scenario>
</x:description>
(base) koala-4:lib djb$ xspec message-test.xspec
Transformation failed: Unknown configuration feature help
Saxon script not found, invoking JVM directly instead.
Creating Test Stylesheet...
Running Tests...
Testing with SAXON EE 10.0
Scenario for testing function get-weights-scale
Invalid window size: 4; window size must be odd integer greater than 3
err:value
FAILED
Formatting Report...
passed: 0 / pending: 0 / failed: 1 / total: 1
Report available at ./xspec/message-test-result.html
Done.
(base) koala-4:lib djb$ cat xspec/message-test-result.xml
<?xml version="1.0" encoding="UTF-8"?>
<x:report xmlns:djb="http://www.obdurodon.org"
xmlns:f="http://www.obdurodon.org/function-variables"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
stylesheet="file:/Users/djb/repos/plot/lib/message-test.xsl"
date="2020-06-28T16:58:12.293-04:00"
xspec="file:/Users/djb/repos/plot/lib/message-test.xspec">
<x:scenario id="scenario1"
xspec="file:/Users/djb/repos/plot/lib/message-test.xspec">
<x:label>Scenario for testing function get-weights-scale</x:label>
<x:call function="djb:get-weights-scale">
<x:param name="f:window-size" select="4"/>
</x:call>
<x:result select="/*">
<pseudo-map xmlns="http://www.jenitennison.com/xslt/xspec">map{"err":map{"column-number":15,"line-number":15,"module":"file:/Users/djb/repos/plot/lib/message-test.xsl","code":Q{http://www.w3.org/2005/xqt-errors}XTMM9000,"value":(),"description":"Processing terminated by xsl:message at line 15 in message-test.xsl. Found while atomizing the result of a call to djb:get-weights-scale#1"}}</pseudo-map>
</x:result>
<x:test id="scenario1-expect1" successful="false">
<x:label>err:value</x:label>
<x:result select="()"/>
<x:expect test="$x:result?err?value/text()" select="/text()">Invalid window size: 4; window size must be odd integer greater than 3</x:expect>
</x:test>
</x:scenario>
</x:report>
(base) koala-4:lib djb$
To view this discussion on the web visit https://groups.google.com/d/msgid/xspec-users/2e791acb-6bda-454a-88df-8c2391dd5642o%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xspec-users/f52e29f5-e321-4322-9bd6-5c8eb7b1cb4eo%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xspec-users/60189a71-5f34-4817-a37b-d280bfd796f7o%40googlegroups.com.