Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Source document at runtime should be removed #423

Closed
AirQuick opened this issue Nov 13, 2018 · 0 comments · Fixed by #437
Closed

Source document at runtime should be removed #423

AirQuick opened this issue Nov 13, 2018 · 0 comments · Fixed by #437
Labels

Comments

@AirQuick
Copy link
Member

Command line and Ant provide a source document when running the tests. But it can be harmful. For example,

do-nothing.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" />

test.xspec

<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="do-nothing.xsl" xmlns:x="http://www.jenitennison.com/xslt/xspec">
	<x:scenario>
		<x:label>Suppose you're testing count() function with child::element() selected but you
			forget to provide the selection context (either inner XML or @href)</x:label>
		<x:call function="count">
			<x:param select="child::element()" />
		</x:call>
		<x:expect label="and you happen to expect 1" select="1" />
	</x:scenario>
</x:description>

This x:param doesn't make sense, but x:expect returns Success without any complaint, because x:param/@select is evaluated in the source document node of the .xspec file.
So the source document can be harmful.

The purpose of the source document is discussed in expath#73. No use case is presented there.
On the other hand, I have one use case:

	<x:call function="my:detect-text-encoding">
		<x:param select="
			'resources/UTF-8.bin'
			=> resolve-uri(document-uri())
			=> saxon:read-binary-resource()" />

This way you can read the binary files relative to the .xspec file. I sometimes use this trick in my production XSpec files.

To sum up, I think

  • The source document at runtime can be harmful or confusing at best. Command line and Ant should remove it.
  • XSpec should provide an alternative way to get the URI of the .xspec file at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant