Previous Up Next


p:parameters

p:parameters — Converts step parameters into XML.

Synopsis

<p:declare-step type="p:parameters">
     <p:input port="parameters" kind="parameter" primary="false"/>
     <p:output port="result" primary="false"/>
</p:declare-step>

Description

The p:parameters step accepts any number of parameters and delivers them back in a c:param-set document.

Each parameter passed to the step is converted into a c:param element. The step resolves duplicate parameters in the normal way (see Section 3, “Parameters”) so at most one parameter with any given name will appear in the result. The resulting c:param elements are wrapped in a c:param-set and the parameter set document is written to the result port.

The p:parameters step always uses the namespace attribute on c:param if the parameter is in a namespace. In other words, the name on the c:param will never contain a colon.

Examples

Pipelines can't directly access parameters by name (because the names of parameters aren't known in advance). To find out what parameters were passed to the pipeline, the p:parameters step is first used to create a document, then that document can be interrogated with XPath.

This pipeline just prints the parameters passed to it (in this case, param with the value “value” and cx:test with the value “othervalue”).

  1 <p:pipeline xmlns:p="http://www.w3.org/ns/xproc" name="main"
                version="1.0">
    
      <p:parameters name="params">
  5     <p:input port="parameters">
          <p:pipe step="main" port="parameters"/>
        </p:input>
      </p:parameters>
    
 10   <p:identity>
        <p:input port="source">
          <p:pipe step="params" port="result"/>
        </p:input>
      </p:identity>
 15 </p:pipeline>
Output
1 <c:param-set xmlns:c="http://www.w3.org/ns/xproc-step">
<c:param name="param" value="value"/>
<c:param name="test"
namespace="http://xmlcalabash.com/ns/extensions"
5 value="othervalue"/>
</c:param-set>

Note that neither the parameters port nor the result output on p:parameters are primary, so we must connect to them explicitly.