Database Reference
In-Depth Information
</body>
</html>
</xsl:template>
</xsl:stylesheet>
To run an XSLT stylesheet over some XML from within XQuery, you need to use an
extension module
. Extension modules are, well, extensions to the basic XQuery capa‐
bilities. eXist has lots of them, and we devote all of
Chapter 7
to the subject. An over‐
view (and all function documentation) is accessible through the XQuery Function
Documentation app, available through the dashboard.
Transforming documents with XSLT is done with the
transform
extension module.
A little XQuery script that performs this transformation is shown in
Example 2-5
,
and its result in
Figure 2-5
.
Example 2-5. Using XSLT with the transform extension module
xquery
version
"3.0"
;
declare
option
exist:serialize
"method=html media-type=text/html"
;
transform:transform
(
doc
(
"/db/apps/exist-book/getting-started/xml-example.xml"
),
doc
(
"/db/apps/exist-book/getting-started/convert-items.xslt"
),
()
)
Figure 2-5. Result of the XSLT transformation
Notice that the
transform
extension module was not explicitly declared in the
XQuery script. eXist does this implicitly for you. The third parameter of
trans
form:transform
, which here is passed an empty sequence, can contain parameters
for the stylesheet.
More about using XSLT transformations within eXist can be found in
“XSLT” on
page 238
.
Search WWH ::
Custom Search