The extension is much farther along. For testing purposes, I have
limited the code to only include two attributes per column and return
only one row. It makes dumpDTM much easier to read.
The code is checked in and ready to compile, watch out it creates a
DTMDump but reuses the same name.
Attached is the test style sheet..
>From what I can see, the DTM Dump is correct..
Here are the problems.
The code
<xsl:variable name="table" select='sql:query($db, $query)'/>
<xsl:copy-of select="$table" />
Causes the query function to be called multiple times where as
the code
<xsl:variable name="table" select='sql:query($db, $query)'/>
<xsl:copy-of select="$table/row-set" />
does not. The code above works closest to the way it is supposed to
except that the column elements are not closed and the column
data is not printed, but for the most part it works. Now it seems
important, whit this XPath statement, it will work with or without
attributes. Only one call to query() and no exceptions, there is only
a problem with the col elements.
The code
<xsl:variable name="table" select='sql:query($db, $query)'/>
<xsl:copy-of select="$table/row-set/column-header" />
Works fine until I add attributes, after I add attributes it prints
correctly but terminates with an exception.
javax.xml.transform.TransformerException:
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1193)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:632)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1079)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1057)
at org.apache.xalan.xslt.Process.main(Process.java:847)
---------
java.lang.NullPointerException:
at
org.apache.xalan.transformer.ResultTreeHandler.isDefinedNSDecl(ResultTreeHandler.java:1424)
at
org.apache.xalan.transformer.ResultTreeHandler.addAttribute(ResultTreeHandler.java:1452)
at
org.apache.xalan.transformer.TreeWalker2Result.startNode(TreeWalker2Result.java:185)
at
org.apache.xml.dtm.ref.DTMTreeWalker.traverse(DTMTreeWalker.java:154)
at
org.apache.xalan.transformer.TreeWalker2Result.traverse(TreeWalker2Result.java:115)
at
org.apache.xalan.templates.ElemCopyOf.execute(ElemCopyOf.java:229)
at
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2142)
at
org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:1969)
at
org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1162)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:632)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1079)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1057)
at org.apache.xalan.xslt.Process.main(Process.java:847)
The code
<xsl:variable name="table" select='sql:query($db, $query)'/>
<xsl:copy-of select="$table/row-set/row" />
Almost works fine without attributes. (The row element is closed but not
the col element's)
but when I attach attributes, I get the exception above.
<?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="'org.enhydra.instantdb.jdbc.idbDriver'"/>
<xsl:param name="datasource" select="'jdbc:idb:./instantdb/sample.prp'"/>
<xsl:param name="query" select="'SELECT * FROM import1'"/>
<xsl:template match="/">
<xsl:variable name="db" select="sql:new($driver, $datasource)"/>
<!-- xsl:if test="sql:connect($db, $driver, $datasource)" -->
<xsl:text> Connection make OK</xsl:text>
<!-- /xsl:if -->
<xsl:variable name="table" select='sql:query($db, $query)'/>
<!--
<xsl:for-each select="$table/row-set/column-header">
<xsl:value-of select="@column-label"/></TH>
</xsl:for-each>
-->
<xsl:variable name="table" select='sql:query($db, $query)'/>
<xsl:copy-of select="$table/row-set/row/col" />
<xsl:value-of select="sql:close($db)"/>
</xsl:template>
</xsl:stylesheet>