xml - Feeding output of <p:xslt> into <c:body> of HTTP PUT request in Xproc -
my goal xproc pipeline below take in source xml document, run 2 xslt transforms <p:xslt> steps, feed output xml after 2nd <p:xslt> <c:body> of <p:http-request> step:
<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" primary="true"/> <p:output port="result" primary="true"/> <p:serialization port="result" indent="false" method="xml" encoding="utf-8" omit-xml-declaration="false" doctype-system="mydtd.dtd" doctype-public="-//doctype-here"/> <p:xslt> <p:input port="stylesheet"> <p:document href="xslt-1.xslt"/> </p:input> </p:xslt> <p:xslt> <p:input port="stylesheet"> <p:document href="xslt-2.xslt"/> </p:input> </p:xslt> <p:http-request omit-xml-declaration="false" encoding="utf-8"> <p:input port="source"> <p:inline> <c:request href="http://localhost:80/myrestserver/dburi/mydoc.xml" auth-method="basic" username="user" password="admin" method="put"> <c:body content-type="text/xml" > </c:body> </c:request> </p:inline> </p:input> </p:http-request> there way achieve this? when try executing code is, <p:http-request> invoked first (puts empty xml file database).
the reason why p:http-request runs first not depend on other steps in pipeline. source input port of p:http-request bound static inline c:request document , therefore step not need wait other steps finish first. step can therefore run @ time.
to fix that, need connect input port of p:http-request second p:xslt step. can done explicitly (using p:pipe) or implicitly (relying on fact xproc processor manufacture implied p:pipe connections automatically). let's demonstrate both while solving main question (embedding output of p:xslt in c:body) in process:
for embedding xml content in xml wrappers, usual go-to xproc steps p:wrap , p:wrap-sequence. however, work simple (one level) xml wrapper elements, not helpful if want wrap in multiple levels of xml (as in case: c:request/c:body). have use else - example p:insert step:
... <p:xslt name="xslt2"> <p:input port="stylesheet"> <p:document href="xslt-2.xslt"/> </p:input> </p:xslt> <p:insert match="c:request/c:body" position="first-child"> <p:input port="source"> <p:inline> <c:request href="http://localhost:80/myrestserver/dburi/mydoc.xml" auth-method="basic" username="user" password="admin" method="put"> <c:body content-type="text/xml"> </c:body> </c:request> </p:inline> </p:input> <p:input port="insertion"> <p:pipe step="xslt2" port="result"/> </p:input> </p:insert> <p:http-request omit-xml-declaration="false" encoding="utf-8"/> ... let's take @ does:
- we gave second
p:xsltstep name (xslt2). - we placed
p:identitystep in between secondp:xsltstep ,p:http-requeststep.p:identitystep uses staticc:request/c:bodydocument insertion target , output of step namedxslt2content inserted. inserts content first child ofc:request/c:body. - we removed static connection
sourceinput port ofp:http-request. fine because output ofp:insertstep flowsourceinput port ofp:http-requestautomatically.
Comments
Post a Comment