PIs and Xspec

13 views
Skip to first unread message

Mark Shellenberger

unread,
May 18, 2022, 6:21:29 PM5/18/22
to XSpec
I'm hoping someone can point me to how to accomplish this task.

I wish to set a PI in an x:context and use it to determine whether an assert is true.  Currently I get an error regarding the context item of the axis for the PI.

I am using oXygen 24.0 and the built in Saxon EE 9.9.1.7.

Thank you.

Error: The context item for axis step root/descendant::processing-instruction(UseDebugMode) is absent

The xspec:
<x:description
    schematron="xspec-PI-test.sch"
    xmlns:x="http://www.jenitennison.com/xslt/xspec">
    <x:scenario
        label="In a document">
        <x:scenario
            label="when the foo element">
            <x:scenario
                label="is present and debug mode is true">
                <x:context>
                    <?useDebugMode test="true"?>
                    <root>
                        <foo />
                    </root>
                </x:context>
                <x:expect-not-assert
                    id="foo-element-exists"
                    label="that is correct" />
            </x:scenario>
            <x:scenario
                label="is absent and debug mode is true">
                <x:context>
                    <?useDebugMode test="true"?>
                    <root/>
                </x:context>
                <x:expect-assert
                    id="foo-element-exists"
                    label="that is incorrect" />
            </x:scenario>
        </x:scenario>
    </x:scenario>
</x:description>

The Schematron:
<sch:schema
    xmlns:sch="http://purl.oclc.org/dsdl/schematron">
   
    <sch:let
        name="use-debug-mode"
        value="substring-before(substring-after(//processing-instruction('UseDebugMode'), 'test=&quot;'), '&quot;')" />
   
    <sch:pattern id="root">
        <sch:rule
            context="root">
            <sch:assert
                diagnostics="foo-element-exists-diagnostic"
                id="foo-element-exists"
                role="fatal"
                test="$use-debug-mode='true'">The foo element child of root exists.</sch:assert>
        </sch:rule>
    </sch:pattern>
   
    <sch:diagnostics>
        <sch:diagnostic
            id="foo-element-exists-diagnostic">A foo element child of root does not exist.</sch:diagnostic>
    </sch:diagnostics>
</sch:schema>





Notice: The information contained in this message or any attached document is confidential and intended only for individuals to whom it is addressed. If you got this message in error, please inform me immediately using one of the methods above. In some cases, I may ask you to return the documents at my expense. In general, please simply destroy the information at once. Any unauthorized use, distribution, or copying of this information is prohibited.

Andrew Sales

unread,
May 19, 2022, 11:08:32 AM5/19/22
to xspec...@googlegroups.com
Hi Mark,
I think you you need to set the global context item by adding run-as='external' to x:description, as per [1].
If I do this, the test suite runs without error.

Regards,
Andrew

--
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-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xspec-users/c8e59ae8-73c1-47b1-ae77-84c56219c34dn%40googlegroups.com.

Mark Shellenberger

unread,
May 24, 2022, 9:40:37 AM5/24/22
to XSpec
Thank you.  That solves the problem.  I really appreciate the guidance.
Reply all
Reply to author
Forward
0 new messages