<?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:output port="result"/>
<p:http-request omit-xml-declaration="false" encoding="UTF-8">
<p:input port="source">
<p:inline>
<c:request href="http://www.proxml.be:8080/check/encoding/"
method="POST">
<c:body content-type="application/xml" >
<a>Ăąƥʥϖℬ≝</a>
</c:body>
</c:request>
</p:inline>
</p:input>
</p:http-request>
</p:declare-step>
<c:request href="http://www.proxml.be:8080/check/encoding/" method="POST">Remark: the request only works for this webservice if the omit-xml-declaration attribute has been explicitly set to 'false', since the posted XML needs to contain the xml declaration to be checked.
<c:body content-type="application/xml" >
<a>Ăąƥʥϖℬ≝</a>
</c:body>
</c:request>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step"
version="1.0">
<p:output port="result"/>
<p:identity name="id">
<p:input port="source">
<p:document href="input.xml"/>
</p:input>
</p:identity>
<p:insert name="ins" match="/c:request/c:body" position="first-child">
<p:input port="source">
<p:inline>
<c:request href="http://www.proxml.be:8080/check/encoding/"
method="POST">
<c:body content-type="application/xml"/>
</c:request>
</p:inline>
</p:input>
<p:input port="insertion">
<p:pipe port="result" step="id"/>
</p:input>
</p:insert>
<p:http-request name="request" omit-xml-declaration="false" encoding="UTF-8"/>
</p:declare-step>
First an external xml file is read and then the insert step is used to insert this xml as first-child into the c:body element, see the XSLTMatch pattern on the match attribute.
The result of this insert step is:
<c:request
xmlns:c="http://www.w3.org/ns/xproc-step"
href="http://www.proxml.be:8080/check/encoding/"
method="POST">
<c:body
xmlns:c="http://www.w3.org/ns/xproc-step"
content-type="application/xml">
<a>Ăąƥʥϖℬ≝</a>
</c:body>
</c:request>
<c:request method="POST" href="http://www.example.com/form-action"where the body contains name=value pairs separated by an &
xmlns:c="http://www.w3.org/ns/xproc-step">
<c:body content-type="application/x-www-form-urlencoded">
name=W3C&spec=XProc
</c:body>
</c:request>
<?xml version="1.0" encoding="UTF-8"?>The resulting request:
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="main"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:html="http://www.w3.org/1999/xhtml" version="1.0">
<p:output port="result"/>
<p:escape-markup name="escape">
<p:input port="source">
<p:inline>
<wrap><a>Hello: Ăąƥʥϖℬ≝</a>
</wrap>
</p:inline>
</p:input>
</p:escape-markup>
<p:www-form-urlencode match="/c:request/c:body/text()">
<p:input port="source">
<p:inline>
<c:request method="POST"
href="http://www.testservice.org/">
<c:body content-type="application/x-www-form-urlencoded">@@HERE@@</c:body>
</c:request>
</p:inline>
</p:input>
<p:with-param name="uid" select="'test'"/>
<p:with-param name="pwd" select="'test'"/>
<p:with-param name="xml" select=".">
<p:pipe port="result" step="escape"/>
</p:with-param>
</p:www-form-urlencode>
<p:http-request/>
</p:declare-step>
<?xml version="1.0" encoding="UTF-8"?>
<c:request
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:html="http://www.w3.org/1999/xhtml"
method="POST"
href="http://www.testservice.org">
<c:body
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:html="http://www.w3.org/1999/xhtml"
content-type="application/x-www-form-urlencoded">uid=test&pwd=test&xml=%3Ca%3EHello:%20%C3%84%E2%80%9A%C3%84%E2%80%A6%C3%86%C2%A5%C3%8A%C2%A5%C3%8F%E2%80%93%C3%A2%E2%80%9E%C2%AC%C3%A2%E2%80%B0%EF%BF%BD%3C/a%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20</c:body>
</c:request>
<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="main"All of the pipelines have been tested and with the latest versions of Calumet and Calabash both run from inside OxygenXML.
xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:c="http://www.w3.org/ns/xproc-step"
xmlns:html="http://www.w3.org/1999/xhtml" version="1.0">
<p:output port="result"/>
<p:escape-markup name="escape">
<p:input port="source">
<p:inline>
<wrap><a>Hello: Ăąƥʥϖℬ≝</a>
</wrap>
</p:inline>
</p:input>
</p:escape-markup>
<p:add-attribute match="c:param" name="xml">
<p:input port="source">
<p:inline>
<c:param name="xml"/>
</p:inline>
</p:input>
<p:with-option name="attribute-name" select="'value'"/>
<p:with-option name="attribute-value" select="wrap/text()">
<p:pipe port="result" step="escape"/>
</p:with-option>
</p:add-attribute>
<p:wrap-sequence name="wrap" wrapper="c:param-set">
<p:input port="source">
<p:inline>
<wrap>
<c:param name="uid" value="test"/>
<c:param name="pwd" value="test"/>
</wrap>
</p:inline>
<p:pipe port="result" step="xml"/>
</p:input>
</p:wrap-sequence>
<p:unwrap match="wrap" name="unwrap"/>
<p:www-form-urlencode match="/c:request/c:body/text()">
<p:input port="source">
<p:inline>
<c:request method="POST"
href="http://www.testservice.org/">
<c:body content-type="application/x-www-form-urlencoded">@@HERE@@</c:body>
</c:request>
</p:inline>
</p:input>
<p:input port="parameters">
<p:pipe port="result" step="unwrap"/>
</p:input>
</p:www-form-urlencode>
<p:http-request/>
</p:declare-step>
UPDATE
Norm Walsh, the editor of the XProc spec and the developer of Calabash commented that PUT and DELETE are supported by XProc.Using following XProc:The method attribute specifies the method to be used against the IRI specified by the href attribute, e.g. GET or POST (the value is not case-sensitive).
<?xml version="1.0" encoding="UTF-8"?>I get following response from Calumet from EMC.
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:c="http://www.w3.org/ns/xproc-step"
version="1.0">
<p:output port="result"/>
<p:http-request omit-xml-declaration="false" encoding="UTF-8">
<p:input port="source">
<p:inline>
<c:request href="http://localhost:8888/exist/rest/db/fruits/Almonds.xml" method="PUT">
<c:body content-type="application/xml" >
<product>
<category>fruits</category>
<item>Almonds</item>
<inventory>
<sku>AlmofruiIV75Lm</sku>
<price>2</price>
<inventory>915</inventory>
</inventory>
<vendor>TriCounty Produce</vendor>
</product>
</c:body>
</c:request>
</p:inline>
</p:input>
</p:http-request>
</p:declare-step>
SystemID: C:\Users\Paul\OxygenWorkspace\XProc\simplePUT.xpl
Engine name: Calumet XProc
Severity: error
Description: XPROC_ERROR: Unsupported request method: PUT
Original message: XPROC_ERROR: Unsupported request method: PUT
UPDATE: Good news coming our way: HTTP PUT will be supported in the upcoming 1.0.11 release.
<c:body content-type="application/octet-stream" encoding="base64">And the PUT has been carried out in eXist-db.
</c:body>
<product xmlns:c="http://www.w3.org/ns/xproc-step">Does anyone have a hint how to get rid of the namespace declaration 'http://www.w3.org/ns/xproc-step'
<category>fruits</category>
<item>Almonds</item>
<inventory>
<sku>AlmofruiIV75Lm</sku>
<price>2</price>
<inventory>915</inventory>
</inventory>
<vendor>TriCounty Produce</vendor>
</product>
in the PUTTED file?
Yes, credits go to Vojtech Toman of EMC.
Changing
<p:inline>
to
<p:inline exclude-inline-prefixes="c">
does the trick.
Comments
Norman Walsh (unauthenticated)
Mar 29, 2010
PUT and DELETE are supported by XProc, though perhaps not by Calumet. I believe XML Calabash supports them.
Ben Griffin (unauthenticated)
Dec 6, 2010
You may be interested in the osi::http model used in Obyx also. Obyx is a language very similar to XProc that was developed independent of XProc. See http://www.obyx.org . REST in the Obyx engine is implemented via libcurl.