Skip to content

Commit

Permalink
modules-build-helper: Support special "px:options" attribute on param…
Browse files Browse the repository at this point in the history
…eter port

For steps that "px:extends" another step, the "px:options" attribute
copies all the options in the specified namespace, and connects the
options with the parameter port.

See nlbdev/pipeline#225 (comment)
  • Loading branch information
bertfrees committed Aug 11, 2020
1 parent affc55d commit 92b6101
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 30 deletions.
2 changes: 1 addition & 1 deletion modules-build-helper/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<groupId>org.daisy.pipeline.build</groupId>
<artifactId>modules-build-helper</artifactId>
<version>2.4.1-SNAPSHOT</version>
<version>2.5.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>

<name>DAISY Pipeline 2 :: Modules Build Helper</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
<c:file name="OSGI-INF/org.daisy.pipeline.modules.impl.Module_it_pipeline_module.xml"/>
<c:file name="OSGI-INF/pf-java-function.xml"/>
<c:file name="OSGI-INF/px-script-option-1.xml"/>
<c:file name="css/__processed__foo.xpl"/>
<c:file name="css/foo-1.css"/>
<c:file name="css/foo-1.xpl"/>
<c:file name="css/foo.css"/>
<c:file name="css/foo.xpl"/>
<c:file name="data-types/script-option-1.xml"/>
<c:file name="data-types/type.xml"/>
<c:file name="impl/JavaFunction$1.class"/>
Expand All @@ -69,6 +73,7 @@
<c:file name="org/daisy/pipeline/script/impl/XProcScript_my_script.class"/>
<c:file name="org/daisy/pipeline/script/impl/XProcScript_my_script_SPI.class"/>
<c:file name="xml/__processed__script-base.xpl"/>
<c:file name="xml/__processed__script-options.xpl"/>
<c:file name="xml/__processed__script.xpl"/>
<c:file name="xml/a.xml"/>
<c:file name="xml/a.xml.xsl"/>
Expand All @@ -89,6 +94,7 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/library.xpl" uri="../xml/library.xpl"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.css" uri="../css/foo.css"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.xpl" uri="../css/__processed__foo.xpl"/>
</catalog>
</x:document>
</x:expect>
Expand Down Expand Up @@ -123,7 +129,7 @@
</x:context>
<x:expect label="The processed script file" type="compare">
<x:document type="inline">
<p:declare-step type="px:script" version="1.0">
<p:declare-step type="px:script" version="1.0" name="step1">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Example script</h1>
<p px:role="desc">Does stuff.</p>
Expand All @@ -141,17 +147,50 @@
For more info see [link](http://example.org/more-info).</p>
</p:documentation>
</p:option>
<p:option name="option-2" required="false" select="'xyz'">
<p:option name="foo:option-1" required="false" select="'xyz'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Option 2</h1>
<h1 px:role="name">Foo option 1</h1>
</p:documentation>
</p:option>
<p:output port="result"/>
<p:import href="foo.xpl"/>
<px:foo/>
<p:option name="bar:option-1" required="false" select="'xyz'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Bar option 1</h1>
</p:documentation>
</p:option>
<p:declare-step type="ex:script" name="main">
<p:input port="source"/>
<p:option name="option-1" required="true"/>
<p:output port="result"/>
<p:input port="foobar-params" kind="parameter"/>
<p:import href="foo.xpl"/>
<px:foo>
<p:input port="params">
<p:pipe step="main" port="foobar-params"/>
</p:input>
</px:foo>
</p:declare-step>
<script xmlns="org.daisy.pipeline.build/modules-build-helper/extend-script.xsl"
name="step2" px:progress="1">
<p:input port="source">
<p:pipe step="step1" port="source"/>
</p:input>
<p:with-param port="foobar-params" name="foo:option-1" select="$foo:option-1"/>
<p:with-param port="foobar-params" name="bar:option-1" select="$bar:option-1"/>
<p:with-option name="option-1" select="$option-1"/>
</script>
</p:declare-step>
</x:document>
</x:expect>
<x:expect label="Namespace binding of 'px' prefix" type="xpath"
test="/*/namespace-uri-for-prefix('px',.)"
equals="'http://www.daisy.org/ns/pipeline/xproc'"/>
<x:expect label="Namespace binding of 'ex' prefix" type="xpath"
test="//*[@type='ex:script']/namespace-uri-for-prefix('ex',.)"
equals="'org.daisy.pipeline.build/modules-build-helper/extend-script.xsl'"/>
<x:expect label="Namespace binding of 'foo' prefix" type="xpath"
test="//*[@name='foo:option-1']/namespace-uri-for-prefix('foo',.)" equals="'foo'"/>
<x:expect label="Namespace binding of 'bar' prefix" type="xpath"
test="//*[@name='bar:option-1']/namespace-uri-for-prefix('bar',.)" equals="'bar'"/>
<x:context label="The OSGI-INF/my-script.xml file">
<x:document type="file" href="${project.build.directory}/it-pipeline-module-${project.version}.jar!/OSGI-INF/my-script.xml"/>
</x:context>
Expand Down Expand Up @@ -262,7 +301,10 @@
<c:file name="src/main/java/overview-summary.html"/>
<c:file name="src/main/java/stylesheet.css"/>
<c:file name="src/main/resources/META-INF/catalog.xml/index.html"/>
<c:file name="src/main/resources/css/foo-1.css/index.md"/>
<c:file name="src/main/resources/css/foo-1.xpl/index.html"/>
<c:file name="src/main/resources/css/foo.css/index.md"/>
<c:file name="src/main/resources/css/foo.xpl/index.html"/>
<c:file name="src/main/resources/data-types/type.xml/index.html"/>
<c:file name="src/main/resources/xml/a.xml/index.html"/>
<c:file name="src/main/resources/xml/foo.xpl/index.html"/>
Expand Down Expand Up @@ -322,11 +364,13 @@
<x:document type="inline">
<c:zipfile name="it-pipeline-module-${project.version}-xprocdoc.jar">
<c:file name="META-INF/MANIFEST.MF"/>
<c:file name="d269e26.html"/>
<c:file name="d269e5.html"/>
<c:file name="d269e51.html"/>
<c:file name="d424e26.html"/>
<c:file name="d424e47.html"/>
<c:file name="d424e5.html"/>
<c:file name="d424e80.html"/>
<c:file name="index.html"/>
<c:file name="libraries.html"/>
<c:file name="org/daisy/pipeline/modules/foo-utils/foo.xpl.html"/>
<c:file name="org/daisy/pipeline/modules/foo-utils/library.xpl.html"/>
<c:file name="overview.html"/>
<c:file name="steps.html"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
xmlns:px="http://www.daisy.org/ns/pipeline">
xmlns:px="http://www.daisy.org/ns/pipeline">
<uri uri="../xml/script.xpl" px:content-type="script" px:id="my-script" px:extends="../xml/script-base.xpl"/>
<uri uri="../xml/script-base.xpl" px:extends="../xml/script-options.xpl"/>
<uri uri="../xml/script-options.xpl" px:extends="../css/foo.xpl"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/library.xpl" uri="../xml/library.xpl"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.css" uri="../css/foo.css"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.xpl" uri="../css/foo.xpl" px:extends="../css/foo-1.xpl"/>
<uri uri="../data-types/type.xml" px:content-type="data-type" px:id="foo:choice"/>
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/liblouis/" uri="../liblouis/"
px:content-type="liblouis-tables" px:include="*"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$option-1: xyz !default;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
xmlns:_="foo">

<p:option name="_:option-1" required="false" select="'abc'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Foo option 1</h1>
</p:documentation>
</p:option>

</p:declare-step>
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$option-1: abc !default;
$option-2: xyz !default;
@use "foo-1.css";
:root {
line-height: 2;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
xmlns:_="foo">

<p:option name="_:option-1" select="'xyz'"/>

<p:option name="_:option-2" required="false" select="'xyz'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Foo option 2</h1>
</p:documentation>
</p:option>

</p:declare-step>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
type="px:foo" version="1.0">
type="px:foo" name="main">

<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>p:foo</p>
Expand All @@ -13,6 +13,8 @@
</p:documentation>
</p:input>

<p:input port="params" kind="parameter"/>

<p:output port="result">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<p>Output port "result"</p>
Expand All @@ -35,7 +37,7 @@
<p:document href="foo.xsl"/>
</p:input>
<p:input port="parameters">
<p:empty/>
<p:pipe step="main" port="params"/>
</p:input>
</p:xslt>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc">
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
xmlns:foo="foo"
xmlns:bar="bar">

<p:input port="source">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
Expand All @@ -9,7 +11,8 @@
</p:input>

<p:option name="option-1"/>
<p:option name="option-2"/>
<p:option name="foo:option-1"/>
<p:option name="bar:option-1"/>

<p:output port="result"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc">
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
xmlns:bar="bar">

<p:option name="option-1" required="true">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
Expand All @@ -19,15 +20,11 @@ For more info see [link](http://example.org/more-info).</p>
</p:pipeinfo>
</p:option>

<p:option name="option-2" required="false" select="'xyz'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Option 2</h1>
</p:documentation>
</p:option>
<p:input port="foo-params" kind="parameter" px:options="foo"/>

<p:option name="option-3" required="false" select="'xyz'">
<p:option name="bar:option-1" required="false" select="'xyz'">
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Option 3</h1>
<h1 px:role="name">Bar option 1</h1>
</p:documentation>
</p:option>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
type="px:script" version="1.0">
type="px:script" name="main">

<p:documentation xmlns="http://www.w3.org/1999/xhtml">
<h1 px:role="name">Example script</h1>
Expand All @@ -10,11 +10,16 @@

<p:input port="source"/>
<p:option name="option-1"/>
<p:option name="option-2"/>
<p:output port="result"/>

<p:input port="foobar-params" kind="parameter" px:options="foo bar"/>

<p:import href="foo.xpl"/>

<px:foo/>
<px:foo>
<p:input port="params">
<p:pipe step="main" port="foobar-params"/>
</p:input>
</px:foo>

</p:declare-step>
Loading

0 comments on commit 92b6101

Please sign in to comment.