SQL Server - XSLT Processor Internal Error: java.lang.NullPo
Posted: Thu May 15, 2014 12:22 am
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>
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>