Saxon SQL 扩展无法在 Saxon 9.8.0.8 PE 或 EE 上使用 XSLT

Saxon SQL extension is not working with XSLT on Saxon 9.8.0.8 PE or EE

目前我正在尝试在 Oracle 数据库上建立一个简单的 sql 连接;通过使用示例中描述的 Saxon SQL 扩展。

但是我的样式表不是在默认使用 Saxon 9.8.0.8 的 Oxygen XML Editor(v20) 上编译的,它没有给我任何线索:

    <xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
        xmlns:bsh="http://bsh-partner.com/PICenter" 
        xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:xs="http://www.w3.org/2001/XMLSchema" 
        xmlns:saxon="http://saxon.sf.net/" 
        xmlns:sql="http://saxon.sf.net/sql"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        exclude-result-prefixes="saxon e xs bsh xsd xsi xsl">    
    <xsl:param name="jdbc.driver"   as="xsd:string" select="'oracle.jdbc.driver.OracleDriver'" />
        <xsl:param name="jdbc.database" as="xsd:string" select="'jdbc:oracle:thin:@localhost:1522/PDPP.MCH.BSHG.COM'" />
        <xsl:param name="jdbc.user" as="xsd:string" select="'dbuser'" />
        <xsl:param name="jdbc.pass" as="xsd:string" select="'dbpassword'" />
        <xsl:variable name="sql.conn" as="java:java.sql.Connection" xmlns:java="http://saxon.sf.net/java-type">
            <sql:connect driver="{$jdbc.driver}" database="{$jdbc.database}" user="{$jdbc.user}" password="{$jdbc.pass}">
                <xsl:fallback>
                    <xsl:message terminate="yes">SQL extenstions are not installed</xsl:message>
                </xsl:fallback>
            </sql:connect>
        </xsl:variable>
<xsl:template match="/e:Envelope/e:Body">
        <log>
            <xsl:apply-templates />
        </log>
    </xsl:template>
</xsl:stylesheet>

当前变量 $sql.conn 给出错误:

Required item type of value of variable $sql.conn is Q{http://saxon.sf.net/java-type}java.sql.Connection; supplied value (<sql:connect {(attr{driver=...}, ...)}/>) has item type element()

所以我无法尝试此扩展如何在我的样式表中工作,任何想法或支持将不胜感激。

声明extension-element-prefixes="sql" (https://www.w3.org/TR/xslt20/#designating-extension-namespace),否则处理器无法将这些元素识别为扩展。

关于 Saxon 处理器在 Oxygen 上设置一些配置的问题相当具体,首先正如文档中所解释的那样,我需要通过参考下面的 xml 对我的转换场景进行特定的 Saxon 配置

<configuration xmlns="http://saxon.sf.net/ns/configuration" edition="EE">
  <global allowExternalFunctions="true" versionOfXml="1.0"/>
  <xslt>
    <extensionElement namespace="http://saxon.sf.net/sql"
      factory="net.sf.saxon.option.sql.SQLElementFactory"/>
  </xslt>
</configuration>

其次,我已将 ojdb6.jar 放入目录 $oxygen-installation-dir/lib 中,然后重新启动 Oxygen 并且扩展可以正常工作,没有任何编译错误!