Skip to content

Commit

Permalink
Further touchups, formatting and renaming for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
wendellpiez committed Jun 26, 2024
1 parent 52e62cb commit 9bad6d1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 39 deletions.
11 changes: 7 additions & 4 deletions smoketest/SMOKETEST-XSPEC.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@

<p:import href="../xspec/xspec-execute.xpl"/>

<p:input port="source">
<p:document content-type="application/xml" href="src/congratulations-xslt.xspec"/>
<p:input port="source" sequence="false">
<!-- For now, running an XSLT XSpec -->
<p:document content-type="application/xml" href="src/congratulations-xslt.xspec"/>
<!--<p:document content-type="application/xml" href="src/doing-well-schematron.xspec"/>-->
<!--<p:document content-type="application/xml" href="src/shout-xquery.xspec"/>-->
</p:input>

<p:identity message="[SMOKETEST-XSPEC] Testing XSpec by running ./congratulations-xslt.xspec"/>
<p:identity message="[SMOKETEST-XSPEC] Testing XSpec by running { base-uri(/) }"/>

<ox:xslt-xspec-execute name="execute-xspec"/>
<ox:xspec-execute name="execute-xspec"/>

<p:identity message="[SMOKETEST-XSPEC] All done, successful run"/>

Expand Down
7 changes: 3 additions & 4 deletions testing/RUN_XSPEC-JUNIT_BATCH.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@

<ox:FILESET_XSPEC name="test-set"/>

<!-- See pipeline RUN_XSPEC_BATCH.xpl for logic capturing HTML also -->
<p:for-each>
<p:with-input pipe="xspec-files@test-set"/>
<!-- Remember that each input node is a root for its own tree - hence XPath context -->
<p:variable name="xspec-filename" select="base-uri(/*)"/>
<p:variable name="relative-path" select="substring-after($xspec-filename,$repo-root)"/>
<p:variable name="html-report-path" select="replace($relative-path,'\.xspec$','') || '_report.html' "/>
<p:variable name="junit-report-path" select="replace($relative-path,'\.xspec$','') || '_junit.xml' "/>

<ox:xspec-execute name="execute-xspec"/>
<ox:execute-xspec name="xspec-execution"/>

<p:store message="[RUN_XSPEC-JUNIT_BATCH] storing JUnit report in {$outdir}/{$junit-report-path}" href="{$outdir}/{$junit-report-path}">
<p:with-input port="source" pipe="xspec-junit-report@execute-xspec"/>
<p:with-input port="source" pipe="xspec-junit-report@xspec-execution"/>
</p:store>
<p:sink/>
</p:for-each>

</p:declare-step>
Expand Down
7 changes: 3 additions & 4 deletions testing/RUN_XSPEC_BATCH.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
<p:variable name="html-report-path" select="replace($relative-path,'\.xspec$','') || '_report.html' "/>
<p:variable name="junit-report-path" select="replace($relative-path,'\.xspec$','') || '_junit.xml' "/>

<ox:xslt-xspec-execute name="execute-xspec"/>
<ox:execute-xspec name="xspec-execution"/>

<p:store message="[RUN_XSPEC_BATCH] storing HTML report in {$outdir}/{$html-report-path}" href="{$outdir}/{$html-report-path}">
<p:with-input port="source" pipe="xspec-html-report@execute-xspec"/>
<p:with-input port="source" pipe="xspec-html-report@xspec-execution"/>
</p:store>
<p:store message="[RUN_XSPEC_BATCH] storing JUnit report in {$outdir}/{$junit-report-path}" href="{$outdir}/{$junit-report-path}">
<p:with-input port="source" pipe="xspec-junit-report@execute-xspec"/>
<p:with-input port="source" pipe="xspec-junit-report@xspec-execution"/>
</p:store>
<p:sink/>
</p:for-each>

</p:declare-step>
Expand Down
6 changes: 4 additions & 2 deletions testing/xproc3-house-rules.sch
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<sch:let name="filename" value="(/*/base-uri() => tokenize('/'))[last()]"/>
<sch:let name="basename" value="replace($filename, '\..*$', '')"/>
<sch:let name="tag" value="'[' || $basename || ']'"/>
<sch:let name="tag-regex" value="'^\[#*\s*(' || $basename || ')\]'"/>

<!--<xsl:variable name="ox:leads-with-variable-reference" as="function(*)"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
Expand Down Expand Up @@ -84,9 +85,10 @@
</sch:rule>

<sch:rule context="*[exists(@message)]">
<sch:let name="parent-label" value="('[' || ../@name || ']')"/>
<sch:let name="parent-label" value="'[' || ../@name || ']'"/>
<sch:let name="parent-label-regex" value="'^\[#*\s*(' || ../@name || ')\]'"/>
<sch:assert sqf:fix="sqf-prepend-message-tag"
test="starts-with(@message,$tag) or ox:leads-with-variable-reference(@message) or (starts-with(@message, $parent-label))">Message should start with tag <sch:value-of select="$tag"/> or label <sch:value-of select="$parent-label"/></sch:assert>
test="matches(@message,$tag-regex) or ox:leads-with-variable-reference(@message) or (matches(@message, $parent-label-regex))">Message should start with tag <sch:value-of select="$tag"/> or label <sch:value-of select="$parent-label"/></sch:assert>
<sqf:fix id="sqf-prepend-message-tag">
<sqf:description>
<sqf:title>Prepend the message with '<sch:value-of select="$tag"/>'</sqf:title>
Expand Down
50 changes: 25 additions & 25 deletions xspec/xspec-execute.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<!-- Providing a relative path to XSpec (top-level directory) on this system. with trailing slash -->
<p:option name="xspec-home" select="'../lib/xspec-3.0.3/'" static="true"/>

<p:declare-step name="xslt-xspec-execute" type="ox:xslt-xspec-execute">
<p:declare-step name="execute-xslt-xspec" type="ox:execute-xslt-xspec">
<p:input port="xspec-source" primary="true" content-types="application/xml"/>
<p:output port="xspec-html-report" primary="true" pipe="result@html-report"/>
<p:output port="xspec-junit-report" primary="false" pipe="result@junit-report"/>
Expand All @@ -34,8 +34,8 @@
match="/*/xsl:template[@name='Q{{http://www.jenitennison.com/xslt/xspec}}main']/xsl:result-document"
attribute-name="href" attribute-value="report" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<!-- Run the XSLT -->
<p:xslt name="execute-xspec"
message="[xslt-xspec-execute] Executing XSPec { base-uri(/) } testing XSLT { /*/@stylesheet }">
<p:xslt name="xslt-xspec-execution"
message="[### execute-xslt-xspec] Executing XSPec { base-uri(/) } testing XSLT { /*/@stylesheet }">
<p:with-input port="source">
<p:empty/>
</p:with-input>
Expand All @@ -44,7 +44,7 @@
</p:xslt>
<!-- Picking up this result and putting it back on the primary port. -->
<p:identity name="xspec-report">
<p:with-input port="source" pipe="secondary@execute-xspec"/>
<p:with-input port="source" pipe="secondary@xslt-xspec-execution"/>
</p:identity>

<ox:produce-html-report name="html-report"/>
Expand All @@ -55,27 +55,27 @@
</ox:produce-junit-report>
</p:declare-step>

<p:declare-step name="xquery-xspec-execute" type="ox:xquery-xspec-execute">
<p:declare-step name="execute-xquery-xspec" type="ox:execute-xquery-xspec">
<p:input port="xspec-source" primary="true" content-types="application/xml"/>

<p:output port="xspec-html-report" primary="true" pipe="result@html-report"/>
<p:output port="xspec-junit-report" primary="false" pipe="result@junit-report"/>

<p:variable name="compiler-xslt" select="$xspec-home || 'src/compiler/compile-xquery-tests.xsl'"/>
<p:variable name="xspec-file-path" select="base-uri(/)"/>
<p:variable name="xquery-target-path" select="resolve-uri(/*/@query-at,$xspec-file-path)"/>
<p:variable name="compiler-xslt" select="$xspec-home || 'src/compiler/compile-xquery-tests.xsl'"/>
<p:variable name="xspec-file-path" select="base-uri(/)"/>
<p:variable name="xquery-target" select="/*/@query-at"/>
<p:variable name="xquery-target-path" select="resolve-uri($xquery-target,$xspec-file-path)"/>

<p:xslt name="compiled-xspec">
<p:with-input port="source" pipe="xspec-source@xquery-xspec-execute"/>
<p:with-input port="source" pipe="xspec-source@execute-xquery-xspec"/>
<p:with-input port="stylesheet" href="{$compiler-xslt}"/>
<p:with-option name="parameters" select="map { 'query-at': $xquery-target-path }"/>
</p:xslt>
<p:xquery name="execute-xspec" message="[xquery-xspec-execute] Executing XQuery XSpec - no runtime messages, sorry">
<p:xquery name="xquery-xspec-execution" message="[### execute-xquery-xspec] Executing XQuery XSpec { $xspec-file-path } testing { $xquery-target } - no runtime messages, sorry">
<p:with-input port="query" pipe="result@compiled-xspec"/>
</p:xquery>
<p:identity name="xspec-report"/>


<ox:produce-html-report name="html-report"/>
<p:sink/>

Expand All @@ -84,7 +84,7 @@
</ox:produce-junit-report>
</p:declare-step>

<p:declare-step name="schematron-xspec-execute" type="ox:schematron-xspec-execute">
<p:declare-step name="execute-schematron-xspec" type="ox:execute-schematron-xspec">
<p:input port="xspec-source" primary="true" content-types="application/xml"/>

<p:output port="xspec-html-report" primary="true" pipe="result@html-report"/>
Expand All @@ -107,7 +107,7 @@

<!-- Pick up XSpec for Schematron and reduce to XSpec for XSLT -->
<p:xslt name="reduce-schematron-xspec">
<p:with-input port="source" pipe="xspec-source@schematron-xspec-execute"/>
<p:with-input port="source" pipe="xspec-source@execute-schematron-xspec"/>
<p:with-input port="stylesheet" href="{ $schematron-xspec-reducer-xslt }"/>
<p:with-option name="parameters" select="map { 'stylesheet-uri': $schematron-xslt-uri }"/>
</p:xslt>
Expand All @@ -127,15 +127,15 @@
match="/*/xsl:template[@name='Q{{http://www.jenitennison.com/xslt/xspec}}main']/xsl:result-document"
attribute-name="href" attribute-value="report" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
<!-- Now, execute -->
<p:xslt name="execute-xspec" message="[schematron-xspec-execute] Executing XSPec { $xspec-file-path } testing Schematron { resolve-uri($target-schematron-path, $xspec-file-path) } ">
<p:xslt name="schematron-xspec-execution" message="[### execute-schematron-xspec] Executing XSPec { $xspec-file-path } testing Schematron { $target-schematron-path } ">
<p:with-input port="source">
<p:empty/>
</p:with-input>
<p:with-input port="stylesheet" pipe="result@adjusted-runtime"/>
<p:with-option name="template-name" select="'Q{http://www.jenitennison.com/xslt/xspec}main'"/>
</p:xslt>
<p:identity name="xspec-report">
<p:with-input port="source" pipe="secondary@execute-xspec"/>
<p:with-input port="source" pipe="secondary@schematron-xspec-execution"/>
</p:identity>

<ox:produce-html-report name="html-report"/>
Expand All @@ -146,26 +146,26 @@
</ox:produce-junit-report>
</p:declare-step>

<p:declare-step name="xspec-execute" type="ox:xspec-execute">
<p:declare-step name="execute-xspec" type="ox:execute-xspec">
<p:input port="xspec-source" primary="true" content-types="application/xml"/>
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@switcher"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@switcher"/>

<p:choose name="switcher">
<p:when test="exists(/x:description/@schematron)">
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@schematron-xspec-execute"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@schematron-xspec-execute"/>
<ox:schematron-xspec-execute name="schematron-xspec-execute"/>
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@schematron-xspec-execution"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@schematron-xspec-execution"/>
<ox:execute-schematron-xspec name="schematron-xspec-execution"/>
</p:when>
<p:when test="exists(/x:description/@stylesheet)">
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@xslt-xspec-execute"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@xslt-xspec-execute"/>
<ox:xslt-xspec-execute name="xslt-xspec-execute"/>
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@xslt-xspec-execution"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@xslt-xspec-execution"/>
<ox:execute-xslt-xspec name="xslt-xspec-execution"/>
</p:when>
<p:when test="exists(/x:description/@query)">
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@xquery-xspec-execute"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@xquery-xspec-execute"/>
<ox:xquery-xspec-execute name="xquery-xspec-execute"/>
<p:output port="xspec-html-report" primary="true" pipe="xspec-html-report@xquery-xspec-execution"/>
<p:output port="xspec-junit-report" primary="false" pipe="xspec-junit-report@xquery-xspec-execution"/>
<ox:execute-xquery-xspec name="xquery-xspec-execution"/>
</p:when>
<p:otherwise>
<p:output port="xspec-html-report" primary="true"/>
Expand Down

0 comments on commit 9bad6d1

Please sign in to comment.