Previous Up Next


p:www-form-urlencode — Encodes parameters into URL encoded form data.


<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 -->


The p:www-form-urlencode step encodes a set of parameter values as an “x-www-form-urlencoded” string and injects it into the input document at the location(s) specified by the match option.

This step is the effectively the opposite of p:www-form-urldecode. The set of parameters is encoded as a single x-www-form-urlencoded string of name/value pairs When parameters are encoded into name/value pairs, only the local name of each parameter is used. The namespace name is ignored and no prefix or colon appears in the name.

The parameters are encoded in document order. That is, the first parameter appears first in the resulting string, the second parameter second, etc. reading from left to right.

The matched nodes are specified with the match pattern in the match option. For each matching node, the encoded string is used in the output.

If the expression given in the match option matches an attribute, the encoded string is used as the new value of the attribute in the output. If the expression matches any other kind of node, the entire node (and not just its contents) is replaced by the encoded string.


In this example, we package up some options as parameters for a web service call.

  1 <p:pipeline xmlns:p=""
  5   <p:option name="a" select="'default a'"/>
      <p:option name="c" select="'default c'"/>
      <p:option name="test" select="'default test'"/>
      <p:www-form-urlencode match="/c:request/@href">
        <p:input port="source">
            <c:request method="get" href="@@"/>
 15       </p:inline>
        <p:with-param name="a" select="$a"/>
        <p:with-param name="c" select="$c"/>
        <p:with-param name="test" select="$test"/>
 20   </p:www-form-urlencode>
      <p:string-replace match="/c:request/@href"
                        replace="concat('', .)"/>
1 <c:request xmlns:c=""

In a real pipeline, we'd almost certainly pass this c:request element on to a p:http-request step, not return it.