From: Hungerburg <pc...@my...> - 2011-10-28 19:51:01
|
Am 2011-10-28 15:27, schrieb Hungerburg: > Hopefully this problem finds some interest: > > Can a self sufficient controller be taught to have a request for > /foo/bar.png return /foo/bar.svg served as a png? > > I tried to make this a two forwards in a view dispatch: > 1 use the xslt servlet to transform svg to FO, > 2 use the xquery servlet to render the result in png, > but dont know how to store/retrieve the intermediate FO. > > The <set-attribute name="xquery.attribute" value="model"/> approach just > doesnt work out for me. I have this now somehow working: Enlightenment started with this sentence from docs: "XQueryURLRewrite passes the HTTP response stream of the previous servlet to the HTTP request received by the next servlet." BUT, I cannot just write my xquery below the forward to XQueryServlet in controller.xql; Instead I have to write it into a variable, and pass that as a string literal through "source". (Otherwise it would always fail because it cannot find the xquery in the original request path.) Code below: > let $query:= 'xquery version "1.0"; > let $foparams := > <parameters> > <param name="FOPauthor" value="Me"/> > <param name="FOPtitle" value="Skizze"/> > <param name="FOPkeywords" value="Skizze KW"/> > <param name="FOPdpi" value="96"/> > </parameters> > return > response:stream-binary( > xslfo:render( > request:get-data(), > "image/png", > $foparams, > ()), > "image/png", > "")' > > […] > else if ($parts[4] eq 'png') then > <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> > <forward url="{$svgd}"/> > <view> > <forward servlet="XSLTServlet"> > <set-attribute name="xslt.stylesheet"value="{concat($view, 'foSKIZZE.xsl')}"/> > <set-attribute name="xslt.output.omit-xml-declaration"value="yes"/> > <set-attribute name="xslt.output.indent" value="yes"/> > <set-attribute name="xslt.output.media-type"value="application/xml"/> > <set-attribute name="xslt.output.method" value="xml"/> > </forward> > <forward servlet="XQueryServlet"> > <set-attribute name="xquery.source" value="{$query}"/> > </forward> > </view> > <cache-control cache="no"/> > </dispatch> There are three redirects: 1) From the controller path (...png) to the path of the svg (xmldb...svg) 2) The xsl transform of SVG to FO 3) The xquery to render the POST data to PNG -- Peter |