From: Werthmuller, D. <dwe...@ct...> - 2013-04-04 20:45:09
|
The documentation is fairly clear how to pass request parameters from an xqueryservlet to the xslt stylesheets, but a bit less clear how to pass all http request parameters to the xsltservlet. http://exist-db.org/exist/apps/doc/urlrewrite.xml?q=xslt%20request%20attribute&field=all&id=D2.2.7#D2.2.7 Here is what we are trying to do: Migrate away from cocoon - very long time cocoon users since 2001, since 2009 we've been using cocoon with eXist-db for content storage. BTW - if there others who have developed controller files that replace cocoon sitemap files and interested in sharing let me know. With a large investment in xsl stylesheets that produce our entire site dynamically, I'd like to retain this investment while we migrate to Exist-db 2.0. Our site makes use of http parameters to select different queries/layouts/output types. For example: http://www.ctg.albany.edu/publications/reports/xml?chapter=2 produces just chapter 2 content from the xml file xml.xml. And http://www.ctg.albany.edu/publications/reports/xml?chapter=2&PrintVersion=1 produces just chapter 2 then uses a separate stylesheet to produce a printer friendly version. And http://www.ctg.albany.edu/publications/reports/xml?chapter=2&PrintVersion=2 produces the same as PDF. These parameters; chapter, PrintVersion and many more control these xslt stylesheets. Question is how do I make these available to the xsl? Here is what I've tried: Relevant sections of a controller.xql Is there an elegant way to get all the parameters regardless of their name? vs request:get-parameter for each? let $query := request:get-parameter("chapter", ()) (: If the not at the root, and requesting a URL with out an extension. Assuming we : are looking for the XML file in the directory with the same name :) else if (ends-with ($exist:path, $resource)) then <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> <forward url="/publications/reports/xml_lessons/xml_lessons.xml"></forward> <set-attribute name="xquery.attribute" value="xslt.chapter"/> <view> <forward servlet="XSLTServlet"> <set-attribute name="xslt.stylesheet" value="xmldb:exist:///db/xmltoolkit/stylesheets/publication.xsl"/> <!-- http request param are passed to XSLT servlet via request attribute --> <set-attribute name="xslt.input" value="xslt.chapter"/> <!-- custom paramters can be passed to the stylesheet this way --> <set-attribute name="xslt.output.media-type" value="text/html"/> <set-attribute name="xslt.output.method" value="xhtml"/> <set-attribute name="xslt.output.doctype-public" value="-//W3C//DTD XHTML 1.0 Transitional//EN"/> <set-attribute name="xslt.output.doctype-system" value="resources/xhtml1-transitional.dtd"/> <set-attribute name="xslt.xinclude-path" value="xmldb:exist:///db/xmltoolkit/stylesheets/"/> </forward> </view> <cache-control cache="no"/> </dispatch> Section of the XSL stylesheet expecting parameters. <!-- get parameters --> <xsl:param name="section"/> <xsl:param name="chapter"/> <xsl:param name="pervious"/> <xsl:param name="next"/> <xsl:param name="sub"/> <xsl:param name="guidelink"/> <xsl:param name="all"/> <xsl:param name="gov"/> <xsl:param name="form"/> <xsl:param name="ekey"/> Thanks Derek |