Re: Transforming the c:param-set document from the parameters port

Hi David,

Your solution (param fixup step before main step) looks absolutely 
viable and well-partitioned.

In XProc 3.0, there won’t be parameter ports any more. Instead, there 
will be an option called 'parameters' that holds a map (from QName to 
item()).

You can still use the existing fixup routine. The XProc 3.0 p:parameters 
step accepts a map and issues a c:param-set document. This document, 
after fixup, can be turned back into a map by means of the p:make-map() 
function (http://spec.xproc.org/master/head/xproc30/#f.make-map).

Alternatively, you will be able to import an XSLT or XQuery function 
library that provides a function for normalizing the incoming parameters 
map directly.

There might be another approach that won’t clutter the sublime beauty of 
your unadulterated main pipeline: Injection. We are contemplating a 
secondary spec that is decoupled from the XProc 3.0 core and step specs. 
A conformant XProc processor will allow you to specify a) matching rules 
for the inputs, outputs or options of steps in pipelines and b) 
interception actions that will be performed on the documents that appear 
on the matching ports, or on the options that are passed to the step. 
Writing diagnostic information to storage is an obvious injection 
application, and input/output/option validation or normalization are 
other conceivable applications. The injected actions might be supplied 
as pipelines or, in the case of options, as XPath functions. Details 
have yet to be determined, but yours seems to be a perfect use case for 
injection.

Gerrit


On 15.10.2017 21:32, David Cramer wrote:
> Thanks, that helped me understand my options. Here's what I've ended up 
> doing. In the example, I pass in gen.summary.tables as 0, but want that 
> to be 'false', and pass in an empty foo and want all empty params to be 
> omitted. A simple fixup-params-xslt does that work:
> 
> https://gist.github.com/dwcramer/9b892924f154f56db777187647776f47
> 
> I have a neurotic need to have a clean-and-simple outermost pipeline. To 
> manipulate the params ahead of time, I can't really have a clean 
> outermost pipeline, but I can move the simple-clean pipeline into a 
> step, which I've called "my-main-pipeline" in the example.
> 
> I'm ok with this--I can nest my dolls in just this way and at least have 
> a simple declaration of what I want to accomplish somewhere :-)
> 
> If it's a common enough situation, some syntactic sugar might be in 
> order in xproc 3.0.
> 
> Thanks!
> David
> 
> On 10/15/17 8:21 AM, Imsieke, Gerrit, le-tex wrote:
>> Hi David,
>>
>> I’m not sure whether I understood the issue at hand. Anyway, I created 
>> this gist: 
>> https://gist.github.com/gimsieke/f3b5534658b2f7240d579230ca17fc4a
>>
>> If you invoke it like (assuming you have a front-end script called 
>> calabash.sh):
>>
>> calabash.sh -p foo=bar -p other-param=other-val 
>> test-param-manipulation.xpl
>>
>> the transformed parameters will be stored as manipulated-params.xml 
>> and look like this:
>>
>> <c:param-set xmlns:c="http://www.w3.org/ns/xproc-step">
>>    <c:param name="param" value="param"/>
>>    <c:param name="foo" namespace="" value="baz"/>
>> </c:param-set>
>>
>> The output will be like:
>>
>> <out xmlns:xs="http://www.w3.org/2001/XMLSchema"
>>      xmlns:c="http://www.w3.org/ns/xproc-step">
>>    <param name="foo" value="baz"/>
>>    <param name="other-param" value=""/>
>>    <param name="param" value="param"/>
>> </out>
>>
>> Does looking at the pipeline answer your questions? If not, I’ll be 
>> back in approx. 2 hours to answer more.
>>
>> Gerrit
>>
>>
>> On 15.10.2017 06:22, David Cramer wrote:
>>> The wonderful thing about posting to a mailing list is that it so 
>>> often inspires you to see the obvious solution immediately /after/ 
>>> you hit Send. Occasionally, the act of composing the message inspires 
>>> me to see the solution before I hit Send, but not this time.
>>>
>>> Obviously, I just need to explicitly declare the result of my 
>>> transformation as the input for the parameters port for any 
>>> subsequent xslt steps or their wrappers:
>>>
>>>       <p:xslt>
>>>          <p:input port="parameters" kind="parameter">
>>>              <p:pipe port="result" step="param-fixup"/>
>>>          </p:input>
>>> ...
>>>
>>> I'd been trying to do that for p:group, but only a step can have a 
>>> parameters port.
>>>
>>> Regards,
>>> David
>>>
>>> On 10/14/17 11:03 PM, David Cramer wrote:
>>>> Some time ago, I learned on this list how to fetch values from the 
>>>> c:param-set that comes in on the parameter port to use in p:variable 
>>>> values in my pipeline: 
>>>> https://lists.w3.org/Archives/Public/xproc-dev/2012May/0005.html
>>>>
>>>> Now I'm attempting to transform that c:param-set before my xslt 
>>>> steps consume it. Transforming the c:param-set is easy enough by 
>>>> taking as input the result of the Geert Josten's ut:parameters 
>>>> utility step: 
>>>> https://github.com/grtjn/xproc-ebook-conv/blob/master/src/nl/grtjn/xproc/util/utils.xpl#L374 
>>>>
>>>>
>>>> However, once the c:param-set is transformed, I haven't figured out 
>>>> how to make subsequent steps in the pipline use the manipulated 
>>>> version.
>>>>
>>>> I could manipulate the parameters in the scripts that call calabash 
>>>> or in the xslts, but it feels like I should be able to run the 
>>>> c:param-set thorough an xslt and then use the result of that in the 
>>>> rest of my pipline.
>>>>
>>>> Is this possible?
>>>>
>>>> Btw., I'm running xmlcalabash-1.1.16-97
>>>>
>>>> Regards,
>>>> David
>>>>
>>>>
>>>
>>
> 
> 

-- 
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsieke@le-tex.de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
------------------------------------------------------------------------------
Meet us at Frankfurt Book Fair
Hall 4.2, L 72.

More at https://www.le-tex.de/en/buchmesse.html

Received on Sunday, 15 October 2017 22:11:26 UTC