RE: Initialize a variable with a parameter port

PS: +1 for a p:parameter function!!

-----Oorspronkelijk bericht-----
Van: Norman Walsh [mailto:ndw@nwalsh.com]
Verzonden: maandag 21 november 2011 20:56
Aan: XProc Dev
Onderwerp: Re: Initialize a variable with a parameter port

Florent Georges <fgeorges@fgeorges.org> writes:
>   I try to get a parameter value in a variable, by connecting the
> variable context to a prameters port and using an expression like
> "/c:param-set/c:param[...]/@value".  But Calabash gives me the
> following error:
>
>     err:XD0008 : More than one document in context for parameter
>     'first' It is a dynamic error if a document sequence appears
>     where a document to be used as the context node is expected.
>
>   I use Calabash 0.9.40.  A complete repro is:

Hmm. Given that there's only one parameter, I'm surprised that doesn't
work. But in the general case, what appears on the parameters input
port is a sequence so that approach isn't going to work reliably
anyway.

The safe way to do this is to wire a p:parameters step into the top of
my:params-try and read from that to initialize the variable. This will,
alas, require another p:group.

Longer term, maybe there should be a p:parameter() *function* that
takes the name of an in-scope parameter and returns its value. Pushing
the parameters into a document in order to read the value back out of
the document does seem like going around the houses.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
Lead Engineer
MarkLogic Corporation
Phone: +1 413 624 6676
www.marklogic.com

Received on Monday, 21 November 2011 21:03:46 UTC