Database Reference
In-Depth Information
In this example, the request is first passed to the createmodel.xq script. This creates
some XML that is subsequently passed to the view1.xsl XSLT stylesheet for transfor‐
mation into HTML.
Another example uses two stylesheets in a pipeline:
<dispatch xmlns= "http://exist.sourceforge.net/NS/exist" >
<forward url= "{concat($exist:controller, " /createmodel.xq")}" />
<view>
<forward servlet= "XSLTServlet" >
<set-attribute name= "xslt.stylesheet"
value= "{concat($exist:root, $exist:controller, " /xslt/view2a.xslt")}" />
</forward>
<forward servlet= "XSLTServlet" >
<set-attribute name= "xslt.stylesheet"
value= "{concat($exist:root, $exist:controller, " /xslt/view2b.xslt")}" />
</forward>
</view>
</dispatch>
This will first create XML by calling createmodel.xq . This is passed to the view2a.xslt
XSLT stylesheet and processed into something else. Finally, the view2b.xslt XSLT
stylesheet which transforms it into HTML.
We pass the name of the stylesheet by setting the xslt.stylesheet request attribute.
Notice that we do a bit of filename juggling there: concat($exist:root, $exist:con
troller, "/xsl/view1.xslt") . This is necessary because stylesheets are expected to
be on the filesystem by default. To execute stylesheets from the database, we have to
explicitly prepend their paths with xmldb:exist:///db/ , and $exist:root starts
with this. You can, of course, hardcode this, but eXist passes enough information in
the controller variables to build this path dynamically, which somewhat isolates you
from possible changes in future.
eXist has multiple servlets, but the one that is useful in this scenario is the XSLT serv‐
let, named XSLTServlet . It is controlled by means of the following attributes:
xslt.stylesheet
The path and name of the XSLT stylesheet to execute. By default, the filesystem is
used. If you want to use a stylesheet stored in the database, prepend this value
with xmldb:exist:///db/ .
xslt.user , xslt.password
The username and password of a database user, used during execution of the
XSLT script when it accesses the database.
xslt.*
Any other attributes starting with xslt. will be passed as stylesheet parameters.
For instance, an attribute called xslt.extra will be available to the stylesheet as
Search WWH ::




Custom Search