XProc steps

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

p:www-form-urlencode

<p:declare-step type="p:www-form-urlencode">
   <p:input port="source" primary="true"/>
   <p:output port="result"/>
   <p:input port="parameters" kind="parameter"/>
   <p:option name="match" required="true"/> <!-- XSLTMatchPattern -->
</p:declare-step>

The <p:www-form-urlencode> step generates from one or several parameters (c:param) a x-www-form-urlencoded compliant string and places it in the source document. The parameters are indicated in the “parameter“ input port. The location where the new entry shall be placed is defined by the “match“ option with an appropriate XSLT expression. The source document is indicated at the “source“ input port. The output is done at the “result“ output port. If the XSLT expression is formulated in such a way that it hits an attribute as target, the string is passed on to this attribute as a value. If the expression hits a node in the target document, it will be completely replaced by the generated string.

Example

In the following example a parameter is indicated and passed on to a target document as attribute value.

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
   <p:input port="source">
      <p:inline>
         <Example>
            <Parameter para=""/>
         </Example>
      </p:inline>
   </p:input>
   <p:output port="result"/>
   <p:www-form-urlencode match="/Example/Parameter/@para">
      <p:input port="parameters">
         <p:inline>
            <c:param name="ExampleName" value="TestValue"/>
         </p:inline>
      </p:input>
   </p:www-form-urlencode>
</p:declare-step>

The result of this process is as follows:

<Example xmlns:c="http://www.w3.org/ns/xproc-step">
   <Parameter xmlns:c="http://www.w3.org/ns/xproc-step" para="ExampleName=TestValue"/>
</Example>