- From: James Sulak <jsulak@gmail.com>
- Date: Wed, 9 Sep 2009 09:12:43 -0500
- To: XProc Dev <xproc-dev@w3.org>
Hello Manifred,
Currently, the output port of your pipeline is implicitly bound to the
output port of the last step within the pipeline, which is the
p:for-each. To achieve what you want, you need to explicitly bind the
pipeline's output port to the result ports of both the p:for-each and
the p:make-absolute-uris. The (untested) code below should do this,
by (1) adding <p:pipe>s to the pipeline's output port declaration, (2)
giving a name to p:make-absolute-uris (so it can be explicitly bound),
and (3) declaring an output port on the p:for-each (so it can be
explicitly bound):
(I'm assuming you want everything on the same result port.
Alternatively, you could define two output ports on your pipeline, one
of which contains the make-absolute-uris result and the other that
contains the for-each result.)
<p:declare-step name="myPipeline"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:p="http://www.w3.org/ns/xproc">
<p:option name="dir"/>
<p:output port="result" sequence="true">
<p:pipe step="make-absolute" port="result"/>
<p:pipe step="directoryloop" port="result" />
</p:output>
<p:serialization port="result" indent="true"
omit-xml-declaration="false"/>
<p:directory-list>
<p:with-option name="path" select="concat($dir, '/')">
<p:empty/>
</p:with-option>
</p:directory-list>
<p:make-absolute-uris match="*/@name" name="make-absolute">
<p:with-option name="base-uri" select="concat($dir, '/')"/>
</p:make-absolute-uris>
<p:for-each name="directoryloop">
<p:iteration-source select="/c:directory/c:directory"/>
<p:output port="result"/>
<p:variable name="dirpath"
select="concat(c:directory/@name, '/')"/>
<p:directory-list>
<p:with-option name="path" select="$dirpath"/>
</p:directory-list>
<p:make-absolute-uris match="c:directory/*/@name">
<p:with-option name="base-uri" select="$dirpath"/>
</p:make-absolute-uris>
<p:make-absolute-uris match="/c:directory/@name">
<p:with-option name="base-uri"
select="substring-before(concat($dirpath, 'iii'), concat(@name,
'/iii'))"/>
</p:make-absolute-uris>
</p:for-each>
</p:declare-step>
You can use <p:pipe>s to make XML flow to or from more than one step
at a time. They're how you describe dependencies between steps when
the default one-step-to-the-next bindings don't work (as in this
case). Hope this helps,
-James
On Wed, Sep 9, 2009 at 7:42 AM, Manfred
Staudinger<manfred.staudinger@gmail.com> wrote:
> I have the following pipeline:
> <?xml version="1.0" encoding="UTF-8"?>
> <p:declare-step name="myPipeline"
> xmlns:c="http://www.w3.org/ns/xproc-step"
> xmlns:p="http://www.w3.org/ns/xproc">
> <p:option name="dir"/>
> <p:output port="result" sequence="true"/>
> <p:serialization port="result" indent="true" omit-xml-declaration="false"/>
> <p:directory-list>
> <p:with-option name="path" select="concat($dir, '/')">
> <p:empty/>
> </p:with-option>
> </p:directory-list>
> <p:make-absolute-uris match="*/@name">
> <p:with-option name="base-uri" select="concat($dir, '/')"/>
> </p:make-absolute-uris>
> <!-- would like to add this to the output _and_ pass it to the
> directoryloop step -->
> <p:for-each name="directoryloop">
> <p:iteration-source select="/c:directory/c:directory"/>
> <p:variable name="dirpath" select="concat(c:directory/@name, '/')"/>
> <p:directory-list>
> <p:with-option name="path" select="$dirpath"/>
> </p:directory-list>
> <p:make-absolute-uris match="c:directory/*/@name">
> <p:with-option name="base-uri" select="$dirpath"/>
> </p:make-absolute-uris>
> <p:make-absolute-uris match="/c:directory/@name">
> <p:with-option name="base-uri"
> select="substring-before(concat($dirpath, 'iii'), concat(@name,
> '/iii'))"/>
> </p:make-absolute-uris>
> </p:for-each>
> </p:declare-step>
>
> When I run this tthen I get a sequence of documents each containing
> one c:directory and its immediate content (c:file and c:directory).
> But I would like to get also the output from the step preceding the
> "directoryloop" step. How would I do this?
>
> Regards,
> Manfred
>
>
Received on Wednesday, 9 September 2009 14:13:24 UTC