Skip to content

Commit

Permalink
Merge branch 'master' into prettier-properties
Browse files Browse the repository at this point in the history
  • Loading branch information
galtm committed Jan 19, 2024
2 parents 61ec8b3 + ed194aa commit 1b231dd
Show file tree
Hide file tree
Showing 118 changed files with 1,675 additions and 675 deletions.
229 changes: 94 additions & 135 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.0.0",
"description": "This package is configured only for testing the XSpec repository",
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-angular": "^18.4.3",
"@commitlint/cli": "^18.4.4",
"@commitlint/config-angular": "^18.4.4",
"bats": "^1.10.0",
"prettier": "^3.1.1",
"prettier-plugin-properties": "^0.3.0"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.12.1</version>
<configuration>
<source>8</source>
<target>8</target>
Expand Down
23 changes: 21 additions & 2 deletions src/compiler/xslt/compile/compile-scenario.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -356,18 +356,37 @@
Local templates
-->

<xsl:template name="local:set-up-context" as="element(xsl:variable)+">
<xsl:context-item use="absent" />
<xsl:template name="local:set-up-context" as="element()+">
<!-- Template output is sequence of xsl:variable+, xsl:if, xsl:variable -->
<!-- Context item is x:context or x:scenario -->
<xsl:context-item as="element()" use="required"/>

<xsl:param name="context" as="element(x:context)" required="yes" tunnel="yes"/>

<!-- Set up the variable of x:context -->
<xsl:apply-templates select="$context" mode="x:declare-variable"/>

<!-- If x:context exists but evaluates to empty at runtime, the
test does not execute any code from the SUT. Assume it was
a user mistake and issue an error message. -->
<if test="empty(${x:variable-UQName($context)})">
<message terminate="yes">
<xsl:call-template name="x:prefix-diag-message">
<xsl:with-param name="message"
select="'Context is an empty sequence.'"/>
</xsl:call-template>
</message>
</if>

<!-- Set up its alias variable ($x:context) for publishing it along with $x:result -->
<xsl:element name="xsl:variable" namespace="{$x:xsl-namespace}">
<xsl:attribute name="name" select="x:known-UQName('x:context')"/>

<!-- Actually, @as is 'item()+'.
But it is loosened to 'item()*', otherwise the static type checking can ruin the runtime
empty sequence checking written above. -->
<xsl:attribute name="as" select="'item()*'" />

<xsl:attribute name="select" select="'$' || x:variable-UQName($context)"/>
</xsl:element>
</xsl:template>
Expand Down
14 changes: 8 additions & 6 deletions src/schemas/xspec.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -348,20 +348,22 @@ expect-valid =
expect-assert =
## In a Schematron test, verify that an <assert> is thrown.
##
## The attributes id, role, and location can be used in combination to
## identify a specific <assert>.
## Text content and the attributes id, role, and location
## can be used in combination to identify a specific <assert>.
element expect-assert {
common-schematron-assert-report-expect-attributes,
schematron-expect-count-attribute
schematron-expect-count-attribute,
text
}
expect-report =
## In a Schematron test, verify that a <report> is thrown.
##
## The attributes id, role, and location can be used in combination to
## identify a specific <report>.
## Text content and the attributes id, role, and location
## can be used in combination to identify a specific <report>.
element expect-report {
common-schematron-assert-report-expect-attributes,
schematron-expect-count-attribute
schematron-expect-count-attribute,
text
}

expect-not-assert =
Expand Down
20 changes: 19 additions & 1 deletion src/schematron/schut-to-xspec.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
<xsl:value-of select="if (@count) then 'count' else 'exists'" />
<xsl:text expand-text="yes">({x:known-UQName('svrl:schematron-output')}/{x:known-UQName('svrl:failed-assert')}</xsl:text>
<xsl:apply-templates select="@*" mode="make-predicate" />
<xsl:apply-templates select=".[normalize-space()]" mode="make-text-predicate" />
<xsl:text>)</xsl:text>
<xsl:value-of select="@count ! (' eq ' || .)" />
</xsl:with-param>
Expand All @@ -143,6 +144,7 @@
<xsl:value-of select="if (@count) then 'count' else 'exists'" />
<xsl:text expand-text="yes">({x:known-UQName('svrl:schematron-output')}/{x:known-UQName('svrl:successful-report')}</xsl:text>
<xsl:apply-templates select="@*" mode="make-predicate" />
<xsl:apply-templates select=".[normalize-space()]" mode="make-text-predicate" />
<xsl:text>)</xsl:text>
<xsl:value-of select="@count ! (' eq ' || .)" />
</xsl:with-param>
Expand Down Expand Up @@ -232,6 +234,21 @@

<xsl:template match="@count | @label | @pending" as="empty-sequence()" mode="make-predicate" />

<xsl:template match="x:expect-assert | x:expect-report" as="text()" mode="make-text-predicate">
<xsl:variable name="x-expect-text-content-wrapped" as="xs:string"
select="normalize-space(.) => x:quote-with-apos()"/>
<!-- Note: Skeleton uses svrl:text for main message and no svrl:text for diagnostics.
SchXslt uses svrl:text for main message and inside svrl:diagnostic-reference.
If XSpec stops supporting skeleton implementation of Schematron, we can
potentially simplify the left side of the '=' expression to
(descendant::{x:known-UQName('svrl:text')}) ! normalize-space(.)
-->
<xsl:text expand-text="yes">[
({x:known-UQName('svrl:text')}, {x:known-UQName('svrl:diagnostic-reference')}) ! normalize-space(.)
= {$x-expect-text-content-wrapped}
]</xsl:text>
</xsl:template>

<!--
Named templates
-->
Expand All @@ -249,7 +266,8 @@
@role,
@location,
@context,
(@count ! ('count:', .))
(@count ! ('count:', .)),
(normalize-space()[.] ! ('text:', .))
)
=> string-join(' ')" />
<xsl:param name="test" as="xs:string" required="yes" />
Expand Down
12 changes: 9 additions & 3 deletions test/as_stylesheet.xspec
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,25 @@

<x:param as="local-xs:double" name="global-param" select="xs:integer(0)" xmlns:local-xs="http://www.w3.org/2001/XMLSchema" />
<x:scenario label="In global-param (i.e. /x:description/x:param), when @as uses a prefix defined in x:param,">
<x:context />
<x:context>
<foo />
</x:context>
<x:expect label="@as takes effect" test="$global-param instance of xs:double" />
</x:scenario>

<x:variable as="local-xs:double" name="myv:global-var" select="xs:integer(0)" xmlns:local-xs="http://www.w3.org/2001/XMLSchema" />
<x:scenario label="In global variable (i.e. /x:description/x:variable), when @as uses a prefix defined in x:variable,">
<x:context />
<x:context>
<foo />
</x:context>
<x:expect label="@as takes effect" test="$myv:global-var instance of xs:double" />
</x:scenario>

<x:scenario label="In scenario-level variable (i.e. //x:scenario/x:variable), when @as uses a prefix defined in x:variable,">
<x:variable as="local-xs:double" name="myv:local-var" select="xs:integer(0)" xmlns:local-xs="http://www.w3.org/2001/XMLSchema" />
<x:context />
<x:context>
<foo />
</x:context>
<x:expect label="@as takes effect" test="$myv:local-var instance of xs:double" />
</x:scenario>

Expand Down
15 changes: 15 additions & 0 deletions test/bad-context/apply-templates/child-constant-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/* exists, but hard-coded @select finds nothing">
<x:context select="/nonexistent">
<foo/>
</x:context>
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
16 changes: 16 additions & 0 deletions test/bad-context/apply-templates/child-variable-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/* exists, but @select computation finds nothing">
<x:variable name="qualifier" select="'nonexistent'" as="xs:string" />
<x:context select="/*[@id=$qualifier]">
<foo/>
</x:context>
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description run-as="external"
stylesheet="../../mirror.xsl"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:import href="child-constant-select.xspec" />
</x:description>
13 changes: 13 additions & 0 deletions test/bad-context/apply-templates/href-broken.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file does not exist">
<x:context href="nonexistent.xml" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file exists, but hard-coded @select finds nothing">
<x:context href="node-selection.xml" />
<x:scenario label="at child level">
<x:context select="/nonexistent" />
<x:expect label="should be error" test="true()" />
</x:scenario>
</x:scenario>

</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file exists, but hard-coded @select finds nothing,">
<x:context href="node-selection.xml" select="/nonexistent" />
<x:scenario label="inherited without more context,">
<x:expect label="should be error" test="true()" />
</x:scenario>
</x:scenario>

</x:description>
13 changes: 13 additions & 0 deletions test/bad-context/apply-templates/href-constant-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file exists, but hard-coded @select finds nothing">
<x:context href="node-selection.xml" select="/nonexistent" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
14 changes: 14 additions & 0 deletions test/bad-context/apply-templates/href-variable-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file exists, but @select computation finds nothing">
<x:variable name="qualifier" select="'nonexistent'" as="xs:string" />
<x:context href="node-selection.xml" select="/*[@id=$qualifier]" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
13 changes: 13 additions & 0 deletions test/bad-context/apply-templates/no-attr.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context has no attributes and no children">
<x:context />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
13 changes: 13 additions & 0 deletions test/bad-context/apply-templates/select-only.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context has no information other than @select">
<x:context select="/missing-context" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
16 changes: 16 additions & 0 deletions test/bad-context/call-template/child-constant-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/* exists, but hard-coded @select finds nothing">
<x:context select="/nonexistent">
<foo/>
</x:context>
<x:call template="mirror:context-mirror" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
17 changes: 17 additions & 0 deletions test/bad-context/call-template/child-variable-select.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/* exists, but @select computation finds nothing">
<x:variable name="qualifier" select="'nonexistent'" as="xs:string" />
<x:context select="/*[@id=$qualifier]">
<foo/>
</x:context>
<x:call template="mirror:context-mirror" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description run-as="external"
stylesheet="../../mirror.xsl"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:import href="child-constant-select.xspec" />

</x:description>
14 changes: 14 additions & 0 deletions test/bad-context/call-template/href-broken.xspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file does not exist">
<x:context href="nonexistent.xml" />
<x:call template="mirror:context-mirror" />
<x:expect label="should be error" test="true()" />
</x:scenario>

</x:description>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description stylesheet="mirror.xsl"
xml:base="../../"
xmlns:mirror="x-urn:test:mirror"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:xs="http://www.w3.org/2001/XMLSchema">

<x:scenario label="x:context/@href file exists, but hard-coded @select finds nothing">
<x:context href="node-selection.xml" />
<x:call template="mirror:context-mirror" />
<x:scenario label="at child level">
<x:context select="/nonexistent" />
<x:expect label="should be error" test="true()" />
</x:scenario>
</x:scenario>

</x:description>

0 comments on commit 1b231dd

Please sign in to comment.