Just wanted to report SUCCESS in using the zip functions and base64 to
send the xml and images to the FOP processor (on tomcat).
The code looks like this (just FYI but maybe someone will dig this up
out of markmail someday :)


This xquery sends the entire contents of the directory containing the
specified uri from the request as a zip, base64 encoded,
then returns the result as a PDF file inline.
The remote end of this request unzips the POST body into a temporary
directory, runs xslt given the base uri, then the FOP processor is
passed the base URI for images as the temporary extracted directory.

-------------------------------  spl_pdf.xquery
---------------------------

declare variable $uri := xdmp:get-request-field("uri","");

xdmp:set-response-content-type("application/pdf"),
xdmp:set-response-code(200,"OK"),
let 
     $files := xdmp:directory( fn:resolve-uri("." , $uri ) )/base-uri(),
         $payload := 
         xs:base64Binary(
                xdmp:zip-create(
                        <parts xmlns="xdmp:zip">{
                for $f in $files return
                                        <part>{$f}</part>   
                        }
                </parts>,
                        for $f in $files return doc($f) 
                )       
                ),
         $result := xdmp:http-post(
concat("http://localhost:8080/xmlsh/spl_pdf.xsh?doc_uri=",$uri), 
<options xmlns="xdmp:http"><data>{$payload}</data></options>
)[2]

return $result

------------------------------------------------------------------

For completeness, the remote side of this looks like :
I'd like to do more of it as a pipeline but several of the external
tools require files, not stdin/out

This uses the xmlsh Servlet  (http://www.xmlsh.org/EmbeddingServlet )

--------------------------------------------------------------
spl_pdf.xsh ------------------
import commands posix
set -content-type application/pdf
TM=/usr/tmp/spl.$$
base=$(xfile -d $TM/$doc_uri)
base64 -d > /tmp/spl.$$.zip
mkdir $TM
unzip -q -d /usr/tmp/spl.$$ /tmp/spl.$$.zip
xslt1 -f /home/dave/epoc/SPL/spl-fo.xsl  -v doc_uri "$base/" >
/tmp/spl.$$.fop  < $TM/$doc_uri
/usr/local/fop/fop -fo /tmp/spl.$$.fop -pdf /tmp/spl.$$.pdf
cat /tmp/spl.$$.pdf
rm -f /tmp/spl.$$.*
rm -rf /usr/tmp/spl.$$
=====================================================================


This all works with a single signin and no passing of credentials or
user/password needed.
Roundtrip time is about 2 sec for a 150k PDF with 5 images (then about
10 seconds for my desktop to render the PDF).
Running on a 5 year old slow commodity linux 32 bit server.

Thanks everyone for the Help, Suggestions, and Patience.


----------------------------------------
David A. Lee
Senior Principal Software Engineer
Epocrates, Inc.
[email protected]
812-482-5224



_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to