I thought I share this one, just in case someone needs to call BaseX (xquery the database in this example) from xslt:
Greets,
Raymond
Example:
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="2.0" exclude-result-prefixes="xsl basex" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:basex="java:org.basex.server.ClientSession">
<!-- create a new ClientSession object (only static methods can be called directly) --> <xsl:variable name="session" select="basex:new('localhost', 1984, 'admin','admin')"/>
<xsl:template match="/">
<!-- putting the xquery in a variable makes it easier to work with quotes or xpath results from the input xml --> <xsl:variable name="query">xsl:textXQUERY for $doc in db:open("SampleDB") return $doc</xsl:text></xsl:variable>
<example> <!-- execute the query with a BaseX command --> xsl:value-of select="basex:execute($session,string($query))"/ </example>
</xsl:template>
</xsl:stylesheet>
basex-talk@mailman.uni-konstanz.de