Skip to content

Commit

Permalink
focus description/context, pending scenario, base-uri on option/param
Browse files Browse the repository at this point in the history
closes #44
fixes #4
  • Loading branch information
josteinaj committed Feb 7, 2017
1 parent f92b155 commit 92e4140
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 12 deletions.
35 changes: 32 additions & 3 deletions src/main/resources/content/xml/schema/xprocspec.rng
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
</attribute>
</optional>
<optional>
<ref name="pending-attribute"/>
<choice>
<ref name="pending-attribute"/>
<ref name="focus-attribute"/>
</choice>
</optional>
</define>

Expand Down Expand Up @@ -158,7 +161,10 @@
</a:documentation>
<ref name="scenario.common"/>
<optional>
<ref name="focus-attribute"/>
<choice>
<ref name="pending-attribute"/>
<ref name="focus-attribute"/>
</choice>
</optional>
<optional>
<choice>
Expand Down Expand Up @@ -253,6 +259,16 @@
with eachother.</p>
</a:documentation>
</attribute>
<optional>
<attribute name="base-uri">
<a:documentation xmlns="http://www.w3.org/1999/xhtml">If the `base-uri` attribute is `temp-dir`, then the base URI in the context
will be the temporary directory used for the test, instead of the base URI of the xprocspec document.
This can be used with for instance `base-uri()` and `resolve-uri('...')`</a:documentation>
<choice>
<value>temp-dir</value>
</choice>
</attribute>
</optional>
</element>
</define>

Expand All @@ -274,6 +290,16 @@
subsequent evaluations of the step does not conflict with eachother.</p>
</a:documentation>
</attribute>
<optional>
<attribute name="base-uri">
<a:documentation xmlns="http://www.w3.org/1999/xhtml">If the `base-uri` attribute is `temp-dir`, then the base URI in the context
will be the temporary directory used for the test, instead of the base URI of the xprocspec document.
This can be used with for instance `base-uri()` and `resolve-uri('...')`</a:documentation>
<choice>
<value>temp-dir</value>
</choice>
</attribute>
</optional>
</element>
</define>

Expand Down Expand Up @@ -306,7 +332,10 @@
<ref name="common-attributes"/>
<ref name="common-elements"/>
<optional>
<ref name="pending-attribute"/>
<choice>
<ref name="pending-attribute"/>
<ref name="focus-attribute"/>
</choice>
</optional>
<ref name="label"/>
</define>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@
</xsl:text>
<p:with-option name="{@name}" select="{@select}">
<xsl:copy-of select="namespace::*"/>
<xsl:if test="not(@xml:base)">
<xsl:attribute name="xml:base" select="if (@base-uri='temp-dir') then $temp-dir else $test-base-uri"/>
</xsl:if>
<p:inline>
<context>
<xsl:attribute name="xml:base" select="$test-base-uri"/>
<xsl:attribute name="xml:base" select="if (@base-uri='temp-dir') then $temp-dir else $test-base-uri"/>
</context>
</p:inline>
</p:with-option>
<!-- TODO: ability to set custom context for p:with-option ? -->
</xsl:for-each>

<xsl:variable name="parameter-ports" select="/*/x:step-declaration/*/p:input[@kind='parameter']"/>
Expand All @@ -98,13 +100,16 @@
<xsl:text>
</xsl:text>
<p:with-param name="{@name}" select="{@select}" port="{$parameter-port}">
<xsl:copy-of select="namespace::*"/>
<xsl:if test="not(@xml:base)">
<xsl:attribute name="xml:base" select="if (@base-uri='temp-dir') then $temp-dir else $test-base-uri"/>
</xsl:if>
<p:inline>
<context>
<xsl:attribute name="xml:base" select="$test-base-uri"/>
<xsl:attribute name="xml:base" select="if (@base-uri='temp-dir') then $temp-dir else $test-base-uri"/>
</context>
</p:inline>
</p:with-param>
<!-- TODO: ability to set custom context for p:with-param ? -->
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@
<p:add-attribute match="/*" attribute-name="test-grammar" attribute-value="Unknown"/>
</p:otherwise>
</p:choose>

<p:for-each name="for-each">
<p:output port="scenarios" sequence="true"/>
<p:variable name="base" select="base-uri(/*)"/>
Expand Down Expand Up @@ -710,7 +710,7 @@
<p:identity/>
</p:otherwise>
</p:choose>
<p:delete match="//@focus"/>
<p:delete match="//x:description/*//@focus"/>

<p:choose>
<p:when test="//x:scenario[@xfail='true']">
Expand Down
23 changes: 22 additions & 1 deletion src/main/resources/content/xml/xproc/xprocspec.xpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,28 @@
<p:variable name="logfile" select="if ($enable-log='true')
then concat($temp-dir,'xprocspec-log-',replace($start-time,'[^\d]',''),'.xml')
else ''"/>


<!-- If there's multiple input documents and some of them has a focus attribute on the root element; don't process the documents without a focus attribute -->
<p:split-sequence test="/*/@focus" name="focus-split"/>
<p:count/>
<p:choose>
<p:when test=".='0'">
<p:identity>
<p:input port="source">
<p:pipe port="not-matched" step="focus-split"/>
</p:input>
</p:identity>
</p:when>
<p:otherwise>
<p:for-each>
<p:iteration-source>
<p:pipe port="matched" step="focus-split"/>
</p:iteration-source>
<p:delete match="/*/@focus"/>
</p:for-each>
</p:otherwise>
</p:choose>

<!--
* Converts any other XProc test syntaxes (currently supported: XProc Test Suite).
* Splits the x:description documents into multiple documents; one for each x:scenario with no dependencies between them.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://www.daisy.org/ns/xprocspec/xprocspec.rng" type="application/xml" schematypens="http://relaxng.org/ns/structure/1.0"?>
<x:description xmlns:x="http://www.daisy.org/ns/xprocspec" xmlns:ex="http://example.net/ns" script="../../steps/temp-dir-option.xpl">

<x:scenario label="temp-dir" pending="Not clear yet whether this is a bug or not; see #44">
<x:scenario label="temp-dir option">
<x:call step="ex:temp-dir-option">
<x:option name="temp-dir" select="'xprocspec temp-dir value'"/>
<x:option name="output-dir" select="$temp-dir"/>
Expand All @@ -11,8 +11,21 @@
<x:document type="port" port="result"/>
</x:context>
<x:expect type="count" label="there should be one document on the result port" min="1" max="1"/>
<x:expect type="xpath" label="the value of the output-dir option should not equal the temp-dir value" test="/*/@output-dir" equals="/*/@temp-dir" xfail="true"/>
<x:expect type="xpath" label="the value of the output-dir option should equal the temp-dir value (options can reference previous options, temp-dir is overridden)" test="/*/@output-dir" equals="/*/@temp-dir"/>
<x:expect type="xpath" label="the value of the $temp-dir variable should not equal the temp-dir value" test="$temp-dir" equals="/*/@temp-dir" xfail="true"/>
</x:scenario>

<x:scenario label="temp-dir base-uri">
<x:call step="ex:temp-dir-option">
<x:option name="temp-dir" select="base-uri()" base-uri="temp-dir"/>
<x:option name="output-dir" select="base-uri()"/>
</x:call>
<x:context label="the result">
<x:document type="port" port="result"/>
</x:context>
<x:expect type="count" label="there should be one document on the result port" min="1" max="1"/>
<x:expect type="xpath" label="the value of the output-dir option should not equal the temp-dir value" test="/*/@output-dir" equals="/*/@temp-dir" xfail="true"/>
<x:expect type="xpath" label="the value of the $temp-dir variable should equal the temp-dir value" test="$temp-dir" equals="/*/@temp-dir"/>
</x:scenario>

</x:description>

0 comments on commit 92e4140

Please sign in to comment.