-
Notifications
You must be signed in to change notification settings - Fork 31
Global Context Item
When the XSpec <x:description>
element does not have @run-as
or has @run-as="import"
, the global context item is absent (the global .
is absent) during the test. Consequently:
-
Named templates are called without a context item if you don't provide
x:context
. - Global parameters and global variables in your stylesheet are always evaluated without a context item.
For example, in this stylesheet
<xsl:stylesheet ...>
<xsl:param name="p" select="foo" />
<xsl:variable name="v" select="base-uri()" />
$p
and $v
rely on the global context item. Testing this stylesheet does not work (the test will be terminated prematurely), because .
is absent when evaluating @select
of $p
and $v
during the test.
One solution is to override $p
and $v
with global x:param
:
<x:description ...>
<x:param name="p" href="source-document.xml" select="foo" />
<x:param name="v" href="source-document.xml" select="base-uri()" />
<x:scenario ...>
Alternatively, you may want to refactor your stylesheet so that the global context item is always accessed indirectly as a single global parameter and then your XSpec can override it with a global x:param
. See tutorial/global-context-item/
.
When /x:description/@run-as
is external
, every XSpec scenario has a different global context item depending on how the tested component is invoked. See its page for details.
If you have any questions about XSpec or want to discuss, contribute, and share information with the XSpec community, please go to our issue tracker.
For historical searches, the Google group might also be useful.
- Writing Scenarios
- Nesting Scenarios
- Focusing Your Efforts
- Global Context Item
- Selecting Nodes
- Whitespace-only Text Nodes
- Attribute Value Templates
- Text Value Templates
- Special Names
- Code Coverage
- XML Catalog Support
- Environment Variables
- Testing Dynamic Errors
- Integrating Your Own Test Helpers
- External Transformation
- Getting Started with XSpec and Schematron
- Writing Scenarios for Schematron
- Testing Schematron with Text Nodes
- Testing Schematron with Attributes
- Using Another Implementation of Schematron