SQL Server - XSLT Processor Internal Error: java.lang.NullPo

Here should go questions about transforming XML with XSLT and FOP.
BearcatTom
Posts: 1
Joined: Wed May 14, 2014 11:31 pm

SQL Server - XSLT Processor Internal Error: java.lang.NullPo

Post by BearcatTom »

I am using Saxon EE and getting a java.lang.NullPointerException when attempting to connect to a SQL Server database.

I have successfully downloaded the Microsoft SQL Server JDBC Driver and loaded the JAR in Oxygen. I am able to access the database using the IDE.

However I get the NullPointerException upon validate. Here is my XSL...any help is much appreciated.

<xsl:stylesheet
xmlns:sql="http://saxon.sf.net/sql"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
xmlns:saxon="http://saxon.sf.net/"
xmlns:java="http://saxon.sf.net/java-type"
extension-element-prefixes="saxon sql">

<xsl:template match="/">
<xsl:choose>
<xsl:when test="element-available('sql:connect')">
<xsl:variable name="connection" as="java:java.sql.Connection">
<sql:connect database="jdbc:sqlserver://localhost;databaseName=purple"
driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
user="sa" password="blah"
xsl:extension-element-prefixes="sql">
<xsl:fallback>
<xsl:message terminate="yes">SQL extensions are not installed</xsl:message>
</xsl:fallback>
</sql:connect>
</xsl:variable>

<sql:close connection="$sql.conn" />
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">sql:connect element is not available</xsl:message>
</xsl:otherwise>
</xsl:choose>

</xsl:template>
</xsl:stylesheet>
Costin
Posts: 829
Joined: Mon Dec 05, 2011 6:04 pm

Re: SQL Server - XSLT Processor Internal Error: java.lang.Nu

Post by Costin »

Hi Tom,

As I have already replied to this through our support email, I also wanted to post the solution for anyone else running into this issue.

When applying transformation scenarios which use resources from a database, besides having the connection to the specific database properly configured, users should also edit their transformation scenario(s), and point it to the driver (.jar file) for their database connection.

Please see below a snippet from my reply to the transformation problem reported above:
Please note that, as the XSLT transformation you are trying to apply needs to connect to an SQL connection, even if you configured the Microsoft SQL Data Source and set up the connection to it in the oXygen Preferences, this is not enough.
Besides of all the above, you should also configure the transformation scenario you're applying to consider the SQL JDBC driver.

Therefore, please open the "Configure Transformation Scenario(s)" dialog, either from oXygen menu Document > Transformation, or by its action in the transformation toolbar, edit the appropriate scenario and point it to the .jar location. To do this, while in the scenario configuration dialog, go to the "Advanced" tab, then to "Libraries" click "Add", browse for the jar file's location and apply changes.
After that try to rerun the transformation and see if you still encounter any issues.
Regards,
Costin
Costin Sandoi
oXygen XML Editor and Author Support
Post Reply