Local variables/parameters in XSpec

Here should go questions about transforming XML with XSLT and FOP.
aaron
Posts: 10
Joined: Fri May 22, 2020 6:44 pm

Local variables/parameters in XSpec

Post by aaron »

I'm trying to better understand local variables/parameters in XSpec.

My XSL adds 'chunk="to-content"' to a bookmap element if the global parameter 'output-format' has value "pdf".

I thought the below would pass testing for both scenarios, by having the output-format parameter inside the first context element, but the first scenario fails. It also fails if I use a variable inside the scenario.

Code: Select all

<!-- Fails -->
<x:scenario label="Bookmap PDF output">
    <x:context>
        <x:param name="output-format" select="'pdf'" as="xs:string"/>
        <bookmap/>
    </x:context>
    <x:expect label="Chunk to-content">
        <bookmap chunk="to-content"/>
    </x:expect>
</x:scenario>

<!-- Passes -->
<x:scenario label="Bookmap Other output">
    <x:context>
        <bookmap/>
    </x:context>
    <x:expect label="No chunking">
        <bookmap/>
    </x:expect>
</x:scenario>
If I use a global variable or parameter, the first scenario then passes, but of course the second fails.

Code: Select all

<!-- Passes -->
<x:param name="output-format" select="'pdf'" as="xs:string"/>
<x:scenario label="Bookmap PDF output">
    <x:context>
        <bookmap/>
    </x:context>
    <x:expect label="Chunk to-content">
        <bookmap chunk="to-content"/>
    </x:expect>
</x:scenario>

<!-- Fails -->
<x:scenario label="Bookmap Other output">
    <x:context>
        <bookmap/>
    </x:context>
    <x:expect label="No chunking">
        <bookmap/>
    </x:expect>
</x:scenario>
I have seen local parameters and variables used with function and template calls, but not with context. Is it at all possible? I have multiple global parameters and variables and I would like to test the different combinations without requiring a separate test file for each.
adrian_sorop
Posts: 73
Joined: Wed Jun 22, 2016 2:48 pm

Re: Local variables/parameters in XSpec

Post by adrian_sorop »

Hi,
Unfortunately, this question is a bit outside of our scope. I think the xspec forum and xspec wiki are the right places to discuss this topic.
Meanwhile, here is the xspec wiki: https://github.com/xspec/xspec/wiki
You can find usefull resources there, like and many others, with proper examples.
Regards,
Adrian S.
Adrian Sorop
<oXygen/> XML Editor
http://www.oxygenxml.com
aaron
Posts: 10
Joined: Fri May 22, 2020 6:44 pm

Re: Local variables/parameters in XSpec

Post by aaron »

Brilliant, thanks Adrian! :D
Post Reply