0

I am trying to test my XSLT 3.0 stylesheet using xspec, but I'm running into a wall.

XSLT: query-utils.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:f="http://www.w3.org/2005/xpath-functions" 
    exclude-result-prefixes="f"
    version="3.0">
    
    <xsl:template name="testtemplate">
        <params>
            <param name="test">This is a test</param>
        </params>
    </xsl:template>

</xsl:stylesheet>

XSPEC: query-utils.xspec

<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
    run-as="import"
    stylesheet="file:/path/to/query-utils.xsl">

    <x:scenario label="dummy test">
        <x:context/>
        <x:call template="testtemplate"/>
        <x:expect label="intentionally wrong">
            <bla/>
        </x:expect>
        <x:expect label="this should be true">
            <params>
                <param name="test">This is a test</param>
            </params>
        </x:expect>
    </x:scenario>
</x:description>

The result is always that both 'expects' fail.

dummy test

intentionally wrong

Result  Expected Result
()      XPath /element() from:

<bla xmlns:x="http://www.jenitennison.com/xslt/xspec" />

this should be true
Result  Expected Result
()      XPath /element() from:

<params xmlns:x="http://www.jenitennison.com/xslt/xspec">
   <param name="test">This is a test</param>
</params>

I've tried multiple Saxon versions on the command-line (9.9 and 10). I've tried running it in OxygenXML (v25, Saxon 11) but I can never get the results as described in e.g. https://github.com/xspec/xspec/wiki

I've tried several variations of the @run-as attribute ('import', 'external', not present), but that makes no difference.

What am I doing wrong or is the xspec framework broken?

Ahmed Sbai
  • 10,695
  • 9
  • 19
  • 38
hepabolu
  • 1,214
  • 4
  • 18
  • 29

1 Answers1

1

I think you shot yourself or XSpec into the foot with <x:context/>, if you remove that simply from your XSpec file/scenario then I think your second test passes.

Martin Honnen
  • 160,499
  • 6
  • 90
  • 110