1) I write a java jdbc program, it works, but from the same machine I can't
get xsl(xalan) to do more than complain about a
"Error Connecting to the Database:Invalid Driver Name Specified!"
2) Does the saxon sql api work better? Is there a "XSLT2.0" best way to
procede?
------------------------------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:sql="org.apache.xalan.lib.sql.XConnection"
extension-element-prefixes="sql">
<xsl:output method="html" indent="yes" />
<xsl:param name="driver" select="'com.ibm.db2.jdbc.net.DB2Driver'"
/>
<xsl:param name="datasource" select="'jdbc:db2:secsdvl1'" />
<xsl:param name="query" select="'SELECT * FROM catentry'" />
<xsl:param name="username" select="'secu'" />
<xsl:param name="passwd" select="'pw'" />
<xsl:template match="/">
<xsl:variable name="db" select="sql:new()" />
<xsl:choose>
<xsl:when test="not(sql:connect($db, $driver,
$datasource, $username, $passwd))">
<xsl:message>
Error Connecting to the
Database:<xsl:value-of select="sql:getError($db)/ext-error" />
</xsl:message>
<html>
<error>
<xsl:copy-of
select="sql:getError($db)" />
</error>
</html>
</xsl:when>
<xsl:otherwise>
<HTML>
<HEAD>
<TITLE>List of
products</TITLE>
</HEAD>
<BODY>
<TABLE border="1">
<xsl:variable
name="table" select='sql:query($db, $query)' />
<!--
Let's
include Error Checking, the error is actually stored
in the
connection since $table will be either data or null
-->
<xsl:if
test="not($table)">
<xsl:message>
Error in Query:<xsl:value-of select="sql:getError($db)/ext-error" />
</xsl:message>
<xsl:copy-of
select="sql:getError($db)" />
</xsl:if>
<TR>
<xsl:for-each select="$table/sql/metadata/column-header">
<TH>
<xsl:value-of select="@column-label" />
</TH>
</xsl:for-each>
</TR>
<xsl:apply-templates
select="$table/sql/row-set/row" />
</TABLE>
</BODY>
</HTML>
<xsl:value-of select="sql:close($db)" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="row">
<TR>
<xsl:apply-templates select="col" />
</TR>
</xsl:template>
<xsl:template match="col">
<TD>
<xsl:value-of select="text()" />
</TD>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list