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:

  1. we gave second p:xslt step name (xslt2).
  2. we placed p:identity step in between second p:xslt step , p:http-request step. p:identity step uses static c:request/c:body document insertion target , output of step named xslt2 content inserted. inserts content first child of c:request/c:body.
  3. we removed static connection source input port of p:http-request. fine because output of p:insert step flow source input port of p:http-request automatically.

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -