RE: XSLT-like command line parameter passing

Hi Yves,

You might find using options easier, though that requires (pre)declaring
all variables you are likely to use..

If you insist on using parameters, you might be interested in looking at
how I do things in my xproc-ebook-conv project. This main.xpl takes
arbitrary parameters, passes them around as parameters throughout the
entire app, uses ut:parameters to merge sequences, and references that
ut:parameters pipe to access parameter values in variables. Look at the
first declare step to get an impression:

https://github.com/grtjn/xproc-ebook-conv/blob/master/src/nl/grtjn/xproc/e
book/main.xpl

The ut:parameters step should be declared somewhere in this library:

https://github.com/grtjn/xproc-ebook-conv/blob/master/src/nl/grtjn/xproc/u
til/utils.xpl

Kind regards,
Geert

> -----Oorspronkelijk bericht-----
> Van: Dr. Yves Forkl [mailto:Y.Forkl@srz.de]
> Verzonden: vrijdag 24 februari 2012 19:27
> Aan: XProc Dev
> Onderwerp: XSLT-like command line parameter passing
>
> Please forgive if this is a trivial question, but I couldn't find an
example of how to
> do this anywhere.
>
> Very much like with XSLT, I would like to reference the value of a
parameter that
> has been passed to the processor from the command line.
>
> The command line part, of course, is easy with Calabash: --with-param
> myparam=myvalue
>
> As far as I have understood, XProc has no global variables, but can pass
> parameters through its steps. However, I can't figure out how to access
the
> parameter within an XPath expression when setting variable myvar in a
step of
> my pipeline:
>
> <p:declare-step name="main" type="srz:pipeline1"
>   xmlns:p="http://www.w3.org/ns/xproc"
>   xmlns:srz="http://xmlns.srz.de/yforkl/xproc"
>   version="1.0">
>   <p:input port="source"/>
>   <p:output port="result" sequence="true"/>
>   <p:input port="parameters" kind="parameter"/>
>
>   ...
>
>   <p:declare-step name="step3" type="srz:step3">
>     <p:input port="source"/>
>     <p:output port="result" sequence="true">
>       <p:pipe step="store-each" port="result"/>
>     </p:output>
>     <p:input port="parameters" kind="parameter"/>
>
>     ...
>
>     <p:variable name="myvar" select="$myparam"/>
>
>     ...
>
>   </p:declare-step>
>
> ....
>   <srz:step3/>
>
> </p:declare-step>
>
>
> Do I need to read out <c:param-set> and parse its <c:param> children? Or
what
> else am I missing?
>
> Yves
>
>

Received on Monday, 27 February 2012 07:33:49 UTC