Skip to content

Commit 92b6101

Browse files
committed
modules-build-helper: Support special "px:options" attribute on parameter 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)
1 parent affc55d commit 92b6101

File tree

12 files changed

+260
-30
lines changed

12 files changed

+260
-30
lines changed

modules-build-helper/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<groupId>org.daisy.pipeline.build</groupId>
1414
<artifactId>modules-build-helper</artifactId>
15-
<version>2.4.1-SNAPSHOT</version>
15+
<version>2.5.0-SNAPSHOT</version>
1616
<packaging>maven-plugin</packaging>
1717

1818
<name>DAISY Pipeline 2 :: Modules Build Helper</name>

modules-build-helper/src/it/it-pipeline-module/src/it/xprocspec/test.xprocspec

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
<c:file name="OSGI-INF/org.daisy.pipeline.modules.impl.Module_it_pipeline_module.xml"/>
4444
<c:file name="OSGI-INF/pf-java-function.xml"/>
4545
<c:file name="OSGI-INF/px-script-option-1.xml"/>
46+
<c:file name="css/__processed__foo.xpl"/>
47+
<c:file name="css/foo-1.css"/>
48+
<c:file name="css/foo-1.xpl"/>
4649
<c:file name="css/foo.css"/>
50+
<c:file name="css/foo.xpl"/>
4751
<c:file name="data-types/script-option-1.xml"/>
4852
<c:file name="data-types/type.xml"/>
4953
<c:file name="impl/JavaFunction$1.class"/>
@@ -69,6 +73,7 @@
6973
<c:file name="org/daisy/pipeline/script/impl/XProcScript_my_script.class"/>
7074
<c:file name="org/daisy/pipeline/script/impl/XProcScript_my_script_SPI.class"/>
7175
<c:file name="xml/__processed__script-base.xpl"/>
76+
<c:file name="xml/__processed__script-options.xpl"/>
7277
<c:file name="xml/__processed__script.xpl"/>
7378
<c:file name="xml/a.xml"/>
7479
<c:file name="xml/a.xml.xsl"/>
@@ -89,6 +94,7 @@
8994
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
9095
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/library.xpl" uri="../xml/library.xpl"/>
9196
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.css" uri="../css/foo.css"/>
97+
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.xpl" uri="../css/__processed__foo.xpl"/>
9298
</catalog>
9399
</x:document>
94100
</x:expect>
@@ -123,7 +129,7 @@
123129
</x:context>
124130
<x:expect label="The processed script file" type="compare">
125131
<x:document type="inline">
126-
<p:declare-step type="px:script" version="1.0">
132+
<p:declare-step type="px:script" version="1.0" name="step1">
127133
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
128134
<h1 px:role="name">Example script</h1>
129135
<p px:role="desc">Does stuff.</p>
@@ -141,17 +147,50 @@
141147
For more info see [link](http://example.org/more-info).</p>
142148
</p:documentation>
143149
</p:option>
144-
<p:option name="option-2" required="false" select="'xyz'">
150+
<p:option name="foo:option-1" required="false" select="'xyz'">
145151
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
146-
<h1 px:role="name">Option 2</h1>
152+
<h1 px:role="name">Foo option 1</h1>
147153
</p:documentation>
148154
</p:option>
149-
<p:output port="result"/>
150-
<p:import href="foo.xpl"/>
151-
<px:foo/>
155+
<p:option name="bar:option-1" required="false" select="'xyz'">
156+
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
157+
<h1 px:role="name">Bar option 1</h1>
158+
</p:documentation>
159+
</p:option>
160+
<p:declare-step type="ex:script" name="main">
161+
<p:input port="source"/>
162+
<p:option name="option-1" required="true"/>
163+
<p:output port="result"/>
164+
<p:input port="foobar-params" kind="parameter"/>
165+
<p:import href="foo.xpl"/>
166+
<px:foo>
167+
<p:input port="params">
168+
<p:pipe step="main" port="foobar-params"/>
169+
</p:input>
170+
</px:foo>
171+
</p:declare-step>
172+
<script xmlns="org.daisy.pipeline.build/modules-build-helper/extend-script.xsl"
173+
name="step2" px:progress="1">
174+
<p:input port="source">
175+
<p:pipe step="step1" port="source"/>
176+
</p:input>
177+
<p:with-param port="foobar-params" name="foo:option-1" select="$foo:option-1"/>
178+
<p:with-param port="foobar-params" name="bar:option-1" select="$bar:option-1"/>
179+
<p:with-option name="option-1" select="$option-1"/>
180+
</script>
152181
</p:declare-step>
153182
</x:document>
154183
</x:expect>
184+
<x:expect label="Namespace binding of 'px' prefix" type="xpath"
185+
test="/*/namespace-uri-for-prefix('px',.)"
186+
equals="'http://www.daisy.org/ns/pipeline/xproc'"/>
187+
<x:expect label="Namespace binding of 'ex' prefix" type="xpath"
188+
test="//*[@type='ex:script']/namespace-uri-for-prefix('ex',.)"
189+
equals="'org.daisy.pipeline.build/modules-build-helper/extend-script.xsl'"/>
190+
<x:expect label="Namespace binding of 'foo' prefix" type="xpath"
191+
test="//*[@name='foo:option-1']/namespace-uri-for-prefix('foo',.)" equals="'foo'"/>
192+
<x:expect label="Namespace binding of 'bar' prefix" type="xpath"
193+
test="//*[@name='bar:option-1']/namespace-uri-for-prefix('bar',.)" equals="'bar'"/>
155194
<x:context label="The OSGI-INF/my-script.xml file">
156195
<x:document type="file" href="${project.build.directory}/it-pipeline-module-${project.version}.jar!/OSGI-INF/my-script.xml"/>
157196
</x:context>
@@ -262,7 +301,10 @@
262301
<c:file name="src/main/java/overview-summary.html"/>
263302
<c:file name="src/main/java/stylesheet.css"/>
264303
<c:file name="src/main/resources/META-INF/catalog.xml/index.html"/>
304+
<c:file name="src/main/resources/css/foo-1.css/index.md"/>
305+
<c:file name="src/main/resources/css/foo-1.xpl/index.html"/>
265306
<c:file name="src/main/resources/css/foo.css/index.md"/>
307+
<c:file name="src/main/resources/css/foo.xpl/index.html"/>
266308
<c:file name="src/main/resources/data-types/type.xml/index.html"/>
267309
<c:file name="src/main/resources/xml/a.xml/index.html"/>
268310
<c:file name="src/main/resources/xml/foo.xpl/index.html"/>
@@ -322,11 +364,13 @@
322364
<x:document type="inline">
323365
<c:zipfile name="it-pipeline-module-${project.version}-xprocdoc.jar">
324366
<c:file name="META-INF/MANIFEST.MF"/>
325-
<c:file name="d269e26.html"/>
326-
<c:file name="d269e5.html"/>
327-
<c:file name="d269e51.html"/>
367+
<c:file name="d424e26.html"/>
368+
<c:file name="d424e47.html"/>
369+
<c:file name="d424e5.html"/>
370+
<c:file name="d424e80.html"/>
328371
<c:file name="index.html"/>
329372
<c:file name="libraries.html"/>
373+
<c:file name="org/daisy/pipeline/modules/foo-utils/foo.xpl.html"/>
330374
<c:file name="org/daisy/pipeline/modules/foo-utils/library.xpl.html"/>
331375
<c:file name="overview.html"/>
332376
<c:file name="steps.html"/>

modules-build-helper/src/it/it-pipeline-module/src/main/resources/META-INF/catalog.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"
3-
xmlns:px="http://www.daisy.org/ns/pipeline">
3+
xmlns:px="http://www.daisy.org/ns/pipeline">
44
<uri uri="../xml/script.xpl" px:content-type="script" px:id="my-script" px:extends="../xml/script-base.xpl"/>
55
<uri uri="../xml/script-base.xpl" px:extends="../xml/script-options.xpl"/>
6+
<uri uri="../xml/script-options.xpl" px:extends="../css/foo.xpl"/>
67
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/library.xpl" uri="../xml/library.xpl"/>
78
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.css" uri="../css/foo.css"/>
9+
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/foo.xpl" uri="../css/foo.xpl" px:extends="../css/foo-1.xpl"/>
810
<uri uri="../data-types/type.xml" px:content-type="data-type" px:id="foo:choice"/>
911
<uri name="http://www.daisy.org/pipeline/modules/foo-utils/liblouis/" uri="../liblouis/"
1012
px:content-type="liblouis-tables" px:include="*"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$option-1: xyz !default;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
3+
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4+
xmlns:_="foo">
5+
6+
<p:option name="_:option-1" required="false" select="'abc'">
7+
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
8+
<h1 px:role="name">Foo option 1</h1>
9+
</p:documentation>
10+
</p:option>
11+
12+
</p:declare-step>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
$option-1: abc !default;
2+
$option-2: xyz !default;
3+
@use "foo-1.css";
14
:root {
25
line-height: 2;
36
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
3+
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4+
xmlns:_="foo">
5+
6+
<p:option name="_:option-1" select="'xyz'"/>
7+
8+
<p:option name="_:option-2" required="false" select="'xyz'">
9+
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
10+
<h1 px:role="name">Foo option 2</h1>
11+
</p:documentation>
12+
</p:option>
13+
14+
</p:declare-step>

modules-build-helper/src/it/it-pipeline-module/src/main/resources/xml/foo.xpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
2+
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
33
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4-
type="px:foo" version="1.0">
4+
type="px:foo" name="main">
55

66
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
77
<p>p:foo</p>
@@ -13,6 +13,8 @@
1313
</p:documentation>
1414
</p:input>
1515

16+
<p:input port="params" kind="parameter"/>
17+
1618
<p:output port="result">
1719
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
1820
<p>Output port "result"</p>
@@ -35,7 +37,7 @@
3537
<p:document href="foo.xsl"/>
3638
</p:input>
3739
<p:input port="parameters">
38-
<p:empty/>
40+
<p:pipe step="main" port="params"/>
3941
</p:input>
4042
</p:xslt>
4143

modules-build-helper/src/it/it-pipeline-module/src/main/resources/xml/script-base.xpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
3-
xmlns:px="http://www.daisy.org/ns/pipeline/xproc">
3+
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4+
xmlns:foo="foo"
5+
xmlns:bar="bar">
46

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

1113
<p:option name="option-1"/>
12-
<p:option name="option-2"/>
14+
<p:option name="foo:option-1"/>
15+
<p:option name="bar:option-1"/>
1316

1417
<p:output port="result"/>
1518

modules-build-helper/src/it/it-pipeline-module/src/main/resources/xml/script-options.xpl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
3-
xmlns:px="http://www.daisy.org/ns/pipeline/xproc">
3+
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4+
xmlns:bar="bar">
45

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

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

28-
<p:option name="option-3" required="false" select="'xyz'">
25+
<p:option name="bar:option-1" required="false" select="'xyz'">
2926
<p:documentation xmlns="http://www.w3.org/1999/xhtml">
30-
<h1 px:role="name">Option 3</h1>
27+
<h1 px:role="name">Bar option 1</h1>
3128
</p:documentation>
3229
</p:option>
3330

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
2+
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="1.0"
33
xmlns:px="http://www.daisy.org/ns/pipeline/xproc"
4-
type="px:script" version="1.0">
4+
type="px:script" name="main">
55

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

1111
<p:input port="source"/>
1212
<p:option name="option-1"/>
13-
<p:option name="option-2"/>
1413
<p:output port="result"/>
1514

15+
<p:input port="foobar-params" kind="parameter" px:options="foo bar"/>
16+
1617
<p:import href="foo.xpl"/>
1718

18-
<px:foo/>
19+
<px:foo>
20+
<p:input port="params">
21+
<p:pipe step="main" port="foobar-params"/>
22+
</p:input>
23+
</px:foo>
1924

2025
</p:declare-step>

0 commit comments

Comments
 (0)