Saxon sql: Unknown extension instruction

Here should go questions about transforming XML with XSLT and FOP.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Saxon sql: Unknown extension instruction

Post by Patrik »

Hi,

i need to import data extracted from my xml documents into an oracle database. Since it is only for internal use the saxon-sql-extension sounds suitble. However, all attempts to get it to work failed so far (using oxygen 16.0)...

my script:

Code: Select all


<xsl:transform version="3.0" 
xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
xmlns:xs = "http://www.w3.org/2001/XMLSchema"
xmlns:err = "http://www.w3.org/2005/xqt-errors"
xmlns:saxon = "http://saxon.sf.net/"
xmlns:sql = "http://saxon.sf.net/sql"
extension-element-prefixes="saxon sql"
exclude-result-prefixes="#all">

<xsl:template match="/">
<xsl:variable name="driver" select="'oracle.jdbc.OracleDriver'"/>
<xsl:variable name="database" select="'jdbc:oracle:thin:@xxx'"/>
<xsl:variable name="user" select="'xxx'"/>
<xsl:variable name="password" select="'xxx'"/>

<xsl:try>
<sql:connect driver="{$driver}" database="{$database}" user="{$user}" password="{$password}"/>
<xsl:message>
<sql:query table="table" column="*"/>
</xsl:message>
<sql:close/>
<xsl:catch>
<xsl:message>ERROR: <xsl:value-of select="$err:description"/></xsl:message>
</xsl:catch>
</xsl:try>
</xsl:template>

</xsl:transform>
This results in the output "[Saxon-EE] ERROR: Unknown extension instruction".

Using xsl:fallback within sql:connect (as int the example provided by saxon) results to a null pointer exception so I uses xsl:try/catch.

saxon9-sql.jar is present in oxygen-lib folder. I also added saxon9-sql.jar explicitly to the transformation scenario but it had no effect.

I uses a configuration file to map the sql namespace to the factory but it had no effect.

Code: Select all

<configuration xmlns="http://saxon.sf.net/ns/configuration" edition="EE">
<global allowExternalFunctions="true" versionOfXml="1.0"/>
<xslt>
<extensionElement namespace="http://net.sf.saxon/sql"
factory="net.sf.saxon.option.sql.SQLElementFactory"/>
</xslt>
</configuration>
Removing the content of the connect-attributes had no effect either so it can't have to do with the oracle driver.

Now I'm runing out of options.

Any ideas what might go wrong? Or is there an alternative to import data from xml (generated with xslt) into an oracle database?

Thanks and regards,

Patrik
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: Saxon sql: Unknown extension instruction

Post by adrian »

Hi,

Your Saxon configuration file uses the wrong namespace for the SQL extension. It should be the same as the one from your XSL, "http://saxon.sf.net/sql". Here's the correct Saxon config file:

Code: Select all

<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>
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: Saxon sql: Unknown extension instruction

Post by Patrik »

Hi Adrian,

Thanks for the hint. Even after you told be I had to use WinMerge to finde the difference...

However, i finally could get sql to work.

Regards,

Patrik
Post Reply