forked from xspec/xspec
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: test $x:xspec-uri variable more (xspec#1792)
- Loading branch information
Showing
8 changed files
with
324 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<t:description | ||
query="x-urn:test:do-nothing" | ||
query-at="do-nothing.xqm" | ||
schematron="do-nothing.sch" | ||
stylesheet="do-nothing.xsl" | ||
xml:base="../../" | ||
xmlns:im="x-urn:test:imported-xspec-uri" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<t:variable name="im:xspec-uri-in-global-var" | ||
select="$t:xspec-uri"/> | ||
|
||
<t:scenario label="$x:xspec-uri defined and checked in imported file"> | ||
<t:call function="true" /> | ||
<!-- Assertion fails when this test file runs and | ||
passes when the importing file, xspec-uri.xspec, runs. | ||
The regular expression is designed to match files named | ||
catalog-01_xspec-uri.xspec and xspec-uri.xspec. | ||
--> | ||
<t:expect label="should be top-level .xspec file that is running" | ||
test="ends-with($im:xspec-uri-in-global-var, '/catalog-01_xspec-uri.xspec') | ||
or ends-with($im:xspec-uri-in-global-var, '/xspec-uri.xspec')" /> | ||
</t:scenario> | ||
|
||
<t:scenario label="Store $x:xspec-uri in variable in imported file" shared="yes"> | ||
<t:variable name="im:xspec-uri-in-local-var" | ||
select="$t:xspec-uri"/> | ||
</t:scenario> | ||
|
||
</t:description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<t:description | ||
query="x-urn:test:do-nothing" | ||
query-at="do-nothing.xqm" | ||
schematron="do-nothing.sch" | ||
stylesheet="do-nothing.xsl" | ||
xml:base="../" | ||
xmlns:im="x-urn:test:imported-xspec-uri" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<t:import href="catalog-01:/imported-xspec-uri.xspec" /> | ||
<t:scenario label="$x:xspec-uri accessed from code in XSpec files imported via XML Catalog"> | ||
<t:call function="true" /> | ||
<t:scenario label="in global variable"> | ||
<t:expect label="should use file:/, not catalog-01:/" | ||
select="$im:xspec-uri-in-global-var => starts-with('file:')" /> | ||
<t:expect label="should equal the value defined in this importing file" | ||
test="$im:xspec-uri-in-global-var eq $t:xspec-uri" /> | ||
</t:scenario> | ||
<t:scenario label="in variable brought into importing file via x:like"> | ||
<t:like label="Store $x:xspec-uri in variable in imported file" /> | ||
<t:expect label="should use file:/, not catalog-01:/" | ||
select="$im:xspec-uri-in-local-var => starts-with('file:')" /> | ||
<t:expect label="should equal the value defined in this importing file" | ||
test="$im:xspec-uri-in-local-var eq $t:xspec-uri" /> | ||
</t:scenario> | ||
</t:scenario> | ||
|
||
</t:description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sch:schema queryBinding="xslt2" | ||
xmlns:sch="http://purl.oclc.org/dsdl/schematron"> | ||
<sch:ns uri="http://www.jenitennison.com/xslt/xspec" prefix="x"/> | ||
|
||
<sch:pattern> | ||
<sch:let name="end-of-test-path" value="'/test/xspec-uri_schematron.xspec'" /> | ||
<sch:let name="xspec-description-id" value="'xspec-uri_schematron'" /> | ||
|
||
<sch:rule context="context-child"> | ||
<sch:report id="context-child-attr-ok" test="ends-with(@attr, $end-of-test-path)" /> | ||
<sch:report id="context-child-text-ok" test="ends-with(text(), $end-of-test-path)" /> | ||
</sch:rule> | ||
|
||
<sch:rule context="x:description"> | ||
<sch:report id="context-select-ok" | ||
test="string(@xml:id) eq $xspec-description-id" | ||
>Identified xspec-uri_schematron.xspec by its /x:description/@xml:id</sch:report> | ||
</sch:rule> | ||
|
||
</sch:pattern> | ||
</sch:schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,104 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<t:description query="x-urn:test:do-nothing" query-at="do-nothing.xqm" | ||
schematron="do-nothing.sch" stylesheet="do-nothing.xsl" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
<t:description expand-text="1" | ||
query="x-urn:test:do-nothing" | ||
query-at="do-nothing.xqm" | ||
schematron="do-nothing.sch" | ||
stylesheet="do-nothing.xsl" | ||
xmlns:im="x-urn:test:imported-xspec-uri" | ||
xmlns:local="x-urn:test:xspec-uri" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<t:variable name="local:end-of-uri" as="xs:string" | ||
select="'/test/xspec-uri.xspec'" /> | ||
|
||
<t:scenario label="$x:xspec-uri in x:call/x:param"> | ||
<t:call function="exactly-one"> | ||
<t:param select="$t:xspec-uri" /> | ||
</t:call> | ||
<t:expect label="should be xs:anyURI" test="$t:result instance of xs:anyURI" /> | ||
<t:expect label="should be this .xspec file" | ||
test="ends-with($t:result, '/test/xspec-uri.xspec')" /> | ||
test="$t:result => ends-with($local:end-of-uri)" /> | ||
<t:expect label="should be the same as the one in x:expect" select="$t:xspec-uri" /> | ||
</t:scenario> | ||
|
||
<t:scenario label="$x:xspec-uri in x:expect"> | ||
<t:call function="true" /> | ||
<t:expect label="in @select, should be this .xspec file" | ||
select="$t:xspec-uri => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in Boolean @test, should be this .xspec file" | ||
test="$t:xspec-uri => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in user-content attribute, should be this .xspec file" | ||
select="/*/@attr/xs:anyURI(.) => ends-with($local:end-of-uri)"> | ||
<element attr="{$t:xspec-uri}" /> | ||
</t:expect> | ||
<t:expect label="in user-content text node, should be this .xspec file" | ||
select="xs:anyURI(.) => ends-with($local:end-of-uri)"> | ||
<element>{$t:xspec-uri}</element> | ||
</t:expect> | ||
<t:scenario label="in filter @test"> | ||
<t:call function="one-or-more"> | ||
<t:param select="('/test/xspec-uri.xspec', 'non-match')"/> | ||
</t:call> | ||
<t:expect label="should be this .xspec file" | ||
test="$t:result[ends-with($t:xspec-uri, .)]" | ||
select="'/test/xspec-uri.xspec'" /> | ||
</t:scenario> | ||
</t:scenario> | ||
|
||
<t:variable name="local:xspec-uri-in-global-var" | ||
select="$t:xspec-uri"/> | ||
<t:variable name="local:xspec-uri-in-global-var-user-content"> | ||
<element attr="{$t:xspec-uri}">{$t:xspec-uri}</element> | ||
</t:variable> | ||
<t:scenario label="$x:xspec-uri in global x:variable"> | ||
<t:call function="true" /> | ||
<t:expect label="in @select, should be this .xspec file" | ||
test="$local:xspec-uri-in-global-var => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in user-content attribute, should be this .xspec file" | ||
test="$local:xspec-uri-in-global-var-user-content/@attr/string() | ||
=> xs:anyURI() => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in user-content text node, should be this .xspec file" | ||
test="$local:xspec-uri-in-global-var-user-content/string() | ||
=> xs:anyURI() => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
|
||
<t:scenario label="$x:xspec-uri in scenario-level x:variable"> | ||
<t:variable name="local:xspec-uri-in-scenario-var" | ||
select="$t:xspec-uri"/> | ||
<t:variable name="local:xspec-uri-in-scenario-var-user-content"> | ||
<element attr="{$t:xspec-uri}">{$t:xspec-uri}</element> | ||
</t:variable> | ||
<t:call function="true" /> | ||
<t:expect label="in @select, should be this .xspec file" | ||
test="$local:xspec-uri-in-scenario-var => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in user-content attribute, should be this .xspec file" | ||
test="$local:xspec-uri-in-scenario-var-user-content/@attr/string() | ||
=> xs:anyURI() => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in user-content text node, should be this .xspec file" | ||
test="$local:xspec-uri-in-scenario-var-user-content/string() | ||
=> xs:anyURI() => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
|
||
<!-- Import XSpec file here using relative path in @href. | ||
test/catalog/catalog-01_xspec-uri.xspec will import the same | ||
file using an XML Catalog reference in @href. --> | ||
<t:import href="catalog/01/imported-xspec-uri.xspec"/> | ||
<t:scenario label="$x:xspec-uri accessed from code in imported XSpec file"> | ||
<t:call function="true" /> | ||
<t:scenario label="in global variable"> | ||
<t:expect label="should be the importing .xspec file, not the imported one" | ||
select="$im:xspec-uri-in-global-var => ends-with($local:end-of-uri)" /> | ||
<t:expect label="should equal the value defined in importing file" | ||
test="$im:xspec-uri-in-global-var eq $t:xspec-uri" /> | ||
</t:scenario> | ||
<t:scenario label="in variable brought into importing file via x:like"> | ||
<t:like label="Store $x:xspec-uri in variable in imported file" /> | ||
<t:expect label="should be the importing .xspec file, not the imported one" | ||
select="$im:xspec-uri-in-local-var => ends-with($local:end-of-uri)" /> | ||
<t:expect label="should equal the value defined in importing file" | ||
test="$im:xspec-uri-in-local-var eq $t:xspec-uri" /> | ||
</t:scenario> | ||
</t:scenario> | ||
|
||
</t:description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<t:description xml:id="xspec-uri_schematron" | ||
schematron="xspec-uri.sch" | ||
xmlns:local="x-urn:test:xspec-uri_schematron" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<!-- Note: /t:description/@xml:id is referenced in xspec-uri.sch --> | ||
|
||
<t:scenario label="$x:xspec-uri in x:context user-content"> | ||
<t:context expand-text="1"> | ||
<context-child attr="{$t:xspec-uri}">{$t:xspec-uri}</context-child> | ||
</t:context> | ||
<t:expect-report id="context-child-attr-ok"/> | ||
<t:expect-report id="context-child-text-ok"/> | ||
</t:scenario> | ||
|
||
<t:scenario label="$x:xspec-uri in x:context/@select"> | ||
<t:context select="$t:xspec-uri[. ne ''] => doc()" /> | ||
<t:expect-report id="context-select-ok"/> | ||
</t:scenario> | ||
|
||
<t:scenario label="Derived .xspec file's @original-xspec attribute"> | ||
<!-- Don't compute the derived .xspec file's URI from $x:xspec-uri | ||
because run-xspec-tests-ant.* puts preprocessed files in a | ||
temporary directory. However, the preprocessed .xsl and .xspec | ||
files are together in that directory. --> | ||
<t:variable name="local:sch-preproc-xspec-uri" | ||
as="xs:string" select="$t:stylesheet-uri => replace('\.xsl$','.xspec')" /> | ||
<t:call function="xs:anyURI"> | ||
<t:param select="doc($local:sch-preproc-xspec-uri)/t:description/@original-xspec | ||
=> exactly-one()" /> | ||
</t:call> | ||
<t:expect label="should match $x:xspec-uri" select="$t:xspec-uri" /> | ||
</t:scenario> | ||
|
||
</t:description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<t:description expand-text="1" | ||
stylesheet="mirror.xsl" | ||
xmlns:local="x-urn:test:xspec-uri_stylesheet" | ||
xmlns:mirror="x-urn:test:mirror" | ||
xmlns:t="http://www.jenitennison.com/xslt/xspec" | ||
xmlns:xs="http://www.w3.org/2001/XMLSchema"> | ||
|
||
<t:variable name="local:end-of-uri" as="xs:string" | ||
select="'/test/xspec-uri_stylesheet.xspec'" /> | ||
|
||
<t:scenario label="$x:xspec-uri in x:context/x:param"> | ||
<t:context mode="mirror:param-mirror"> | ||
<t:param name="param-items" select="$t:xspec-uri" /> | ||
<element /> | ||
</t:context> | ||
<t:expect label="should be this .xspec file" | ||
test="$t:result => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
|
||
<t:scenario label="$x:xspec-uri in x:context user-content"> | ||
<t:context mode="mirror:context-mirror"> | ||
<element attr="{$t:xspec-uri}">{$t:xspec-uri}</element> | ||
</t:context> | ||
<t:expect label="in attribute value, should be this .xspec file" | ||
test="$t:result/@attr => ends-with($local:end-of-uri)" /> | ||
<t:expect label="in text node, should be this .xspec file" | ||
test="$t:result/text() => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
|
||
<t:scenario label="$x:xspec-uri in x:context/@select"> | ||
<t:context mode="mirror:context-mirror" | ||
select="$t:xspec-uri[. ne ''] => doc()" /> | ||
<t:expect label="should be this .xspec file" | ||
test="$t:result => base-uri() => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
|
||
<t:helper stylesheet="global-override.xsl" /> | ||
<t:param name="global-x-param_vs_xsl-param" select="$t:xspec-uri" /> | ||
<t:scenario label="$x:xspec-uri in x:description/x:param"> | ||
<t:context select="'global-x-param_vs_xsl-param'" /> | ||
<t:expect label="should be this .xspec file" | ||
test="$t:result => ends-with($local:end-of-uri)" /> | ||
</t:scenario> | ||
</t:description> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters