Database Reference
In-Depth Information
<parameters>
<param
name=
"par1"
value=
"value of par1"
/>
<param
name=
"par2"
value=
"value of par2"
/>
<!-- ...any further parameters -->
</parameters>
You reference these in your stylesheet by specifying global parameters with the same
names. For instance:
<xsl:stylesheet
version=
"1.0"
xmlns:xsl=
"http://www.w3.org/1999/XSL/Transform"
>
<xsl:param
name=
"par1"
/>
<xsl:param
name=
"par2"
/>
<xsl:template
match=
"/"
>
<p>
Values passed were
<xsl:value-of
select=
"$par1"
/>
and
<xsl:value-of
select=
"$par2"
/></p>
</xsl:template>
</xsl:stylesheet>
There are two special parameters defined:
exist:stop-on-error
If this parameter is present and set to
yes
, an XQuery error is generated if the
XSLT processor reports an error.
exist:stop-on-warning
If this parameter is present and set to
yes
, an XQuery error is generated if the
XSLT processor reports a warning.
Most errors emitted by the XSLT processor are of the category
fatal
and will stop
the processing anyway.
Invoking XSLT by Processing Instruction
Another way of invoking XSLT is by adding a
<?xml-stylesheet type="text/xsl"
href="..."?>
processing instruction at the top of your output. The
href
attribute
should contain a reference to an XSLT stylesheet. Relative names are taken from the
location of the originating XML.
Although normal use for this processing instruction is for triggering
client-side
XSLT
processing (in the browser), in an eXist context it triggers
server-side
XSLT processā
ing. This means the client will see the output of the transformation.
There is a nice example of this in the eXist demo application. If you look in
/db/apps/
demo/data
, you'll find some Shakespeare plays marked up in XML. At the top of
these XML files is the processing instruction
<?xml-stylesheet href="shakes.xsl"
type="text/xsl"?>
. The same collection holds the referenced
shakes.xsl
document,
which contains an XSLT stylesheet that renders a play in HTML. See this in action by
browsing to, for instance,
http://localhost:8080/exist/rest/db/apps/demo/data/
macbeth.xml
.
Search WWH ::
Custom Search