Re: Form urlencode/decode for p:http-request?

/ Norman Walsh <ndw@nwalsh.com> was heard to say:
| Do we need something to make it easier to construct x-www-form-urlencoded
| parameters? I was thinking of letting p:http-request take parameters,
| now I'm thinking maybe p:form-urlencode/p:form-urldecode. I'll experiment
| a little.

I propose the following pair of steps for handling x-www-form-urlencoded
parameters:

*** p:www-form-urlencode

The p:www-form-urlencode step encodes a set of parameter values as a
x-www-form-urlencoded string and inejcts it into the source document.

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

The value of the match option must be an XSLTMatchPattern.

The set of parameters is encoded as a single x-www-form-urlencoded string.

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. Nodes that do not match are copied without change.

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.

*** p:www-form-urldecode

The p:www-form-urldecode step decodes a x-www-form-urlencoded string
into a set of parameters.

<p:declare-step type="p:www-form-urldecode">
 <p:output port="result"/>
 <p:option name="value" required="true"/>
</p:declare-step>

The value option is interpreted as a string of parameter values
encoded using the x-www-form-urlencoded algorithm. It turns each such
encoded name/value pair into a parameter. The entire set of parameters
is written (as a c:parameter-set) on the result output port.

It is a dynamic error (err:XC0037) if the value provided is not a
properly x-www-form-urlencoded value.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh <ndw@nwalsh.com> | Everything should be made as simple as
http://nwalsh.com/            | possible, but no simpler.

Received on Tuesday, 13 November 2007 16:24:26 UTC