Special Names - xspec/xspec GitHub Wiki

This page documents names of variables that XSpec predefines for your use, as well as other special names that XSpec expects you to use to access certain features.

By convention, the descriptions on this page use the prefix x and assume the XSpec file has the namespace declaration, xmlns:x="http://www.jenitennison.com/xslt/xspec". You can use any prefix that you have bound to the same namespace URI.

@x:attrs="..."

Starting in XSpec v3.0.3: When x:expect contains descendant XML elements where you want the comparison of actual result and expected result to ignore attributes that you haven't explicitly specified, set x:attrs="..." on those elements.

For more information, see Ignoring some portions (...) in the expected result.

$x:context

Context in an XSLT or Schematron scenario.

This predefined variable is available within the @test and @select attributes of x:expect.

Starting in XSpec v3.0.3, this predefined variable is available in any part of the scenario following x:context itself.

If context information is divided among a scenario and its descendant scenarios, $x:context reflects the information available at the point of the reference. If you want to capture the context information that a descendant scenario actually uses to exercise the test target, reference this variable after that descendant scenario's x:context element.

@x:expand-text

To enable or disable text value templates on a non-XSpec element and its descendants, use the @x:expand-text attribute. This attribute name is in the XSpec namespace precisely because the element itself is not in the XSpec namespace.

For more information, see Text Value Templates.

$x:result

Raw result of running the test target. This predefined variable is available within the @test attribute of x:expect.

For more information and contrast with the context item (.), see Accessing the raw actual result ($x:result) in @test.

$x:saxon-config

Name of an XSpec variable that you create using x:variable (i.e., not a predefined variable that XSpec creates) if you want to configure Saxon options for a test that uses @run-as="external".

For more information, see Saxon Configuration.

$x:xspec-uri

Absolute URI of the top-level XSpec file that is running.

This predefined variable is available within scenarios, global x:variable elements, and global x:param elements.

This variable is useful for resolving the URIs of supporting files with respect to the XSpec file URI, in situations where the standard @href attribute in XSpec is not applicable.

In tests for Schematron, $x:xspec-uri is the URI of your test, not the URI of the test that XSpec generates as an intermediate file in the Schematron testing process.

Example

<x:param select="
  'resources/UTF-8.bin'
  => resolve-uri($x:xspec-uri)
  => saxon:read-binary-resource()" />

While the example above uses saxon:read-binary-resource() to access the resolved URI, consider using $x:xspec-uri when a test needs to read an external file using unparsed-text() or doc().

Imported XSpec files

If the reference to $x:xspec-uri is located in an imported XSpec file:

  • The value still reflects the top-level file.
  • The value uses file: even if the x:import element used a catalog to locate the file to import.