Gary,

Are you sure you have the latest. I had to change the name of the <col>
tag to <column> since it seems that <col> has special meaning to the
XSLTC stuff (see prior message). When I use <col>, you don't get a
closing tag or data, <column> works fine though.

JohnG

Gary L Peskin wrote:

> John --
>
> I must confess that I have not really been "into" the SQL Extension
> code.  However, I took your stylesheet with the latest CVS build.  I
> changed to using the JDBC-ODBC with my desktop Access setup and for the
>
>   <xsl:copy-of select="$table/row-set/" />
>
> my response was
>
>   <row-set>
>   <column-header column-label="Field1"
> column-name="Field1"></column-header>
>   <column-header column-label="Field2"
> column-name="Field2"></column-header>
>   <column-header column-label="Field3"
> column-name="Field3"></column-header>
>   <row>
>   <col column-label="Field1" column-name="Field1">
>   <col column-label="Field2" column-name="Field2">
>   <col column-label="Field3" column-name="Field3">
>   </row>
>   <row>
>   <col column-label="Field1" column-name="Field1">
>   <col column-label="Field2" column-name="Field2">
>   <col column-label="Field3" column-name="Field3">
>   </row>
>   </row-set>
>
> which sort of looked okay to me except the field values are not shown
> and there is no closing tag for the col element.
>
> When I changed the select to $table/row-set/row/*, I get
>
> javax.xml.transform.TransformerException:
>         at
> org.apache.xalan.transformer.TransformerImpl.transformNode(Compiled C
> ode)
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(Compiled Code)
>
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
> l.java:1079)
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
> l.java:1057)
>         at org.apache.xalan.xslt.Process.main(Compiled Code)
> ---------
> java.lang.NullPointerException:
>         at
> org.apache.xalan.transformer.ResultTreeHandler.isDefinedNSDecl(Result
> TreeHandler.java:1424)
>         at
> org.apache.xalan.transformer.ResultTreeHandler.addAttribute(ResultTre
> eHandler.java:1452)
>         at
> org.apache.xalan.transformer.TreeWalker2Result.startNode(Compiled Cod
> e)
>         at org.apache.xml.dtm.ref.DTMTreeWalker.traverse(Compiled Code)
>         at
> org.apache.xalan.transformer.TreeWalker2Result.traverse(TreeWalker2Re
> sult.java:115)
>         at org.apache.xalan.templates.ElemCopyOf.execute(Compiled Code)
>         at
> org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(Co
> mpiled Code)
>         at
> org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(Tran
> sformerImpl.java:1969)
>         at
> org.apache.xalan.transformer.TransformerImpl.transformNode(Compiled C
> ode)
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(Compiled Code)
>
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
> l.java:1079)
>         at
> org.apache.xalan.transformer.TransformerImpl.transform(TransformerImp
> l.java:1057)
>         at org.apache.xalan.xslt.Process.main(Compiled Code)
>
> so there must be something wrong with the result tree building, I
> guess.  I'll have a look DTMDump.txt and see if I see anything there.
>
> Anyway, as I said, I'm new to all of this but I'm willing to work with
> you so that you can wrap this up!  Sometimes, having someone to bounce
> ideas off of is just what's needed.
>
> Gary
>
> John Gentilin wrote:
> >
> > Gary,
> >
> > The easiest way is to change XConnection#query() method
> > in the SQL Extension code to return null. For me this usually
> > happens when an exception is thrown. As I said, the transformation
> > works correctly it is just Process that refuses to terminate. So I
> > get all my information including data added to the result tree
> > after query() returns null.
> >
> > Attached is a sample Stylesheet I have been using, although it
> > does not really matter.
> >
> > If you have the time to look at this, I am also having another
> > problem that is really hanging me up. If I execute an XPath
> > statement and the select specifies the extent on a tree, it
> > will result in an exception. So if I have the code
> >
> > <xsl:copy-of select="$table/row-set/row/column" />
> >
> > An exception will occur where as if I execute the following.
> >
> > <xsl:copy-of select="$table/row-set/row" />
> > Not only will the exception NOT occur, the data is transferred
> > to the result tree just fine.
> >
> > The same occurs for the following code pair
> > <xsl:copy-of select="$table/row-set/column-header" />
> > and
> > <xsl:copy-of select="$table/row-set" />
> >
> > The only difference I can see is that the XPath statement
> > specifies all the elements in the selected branch.
> >
> > Regards
> > John G
> >
> > Gary L Peskin wrote:
> >
> > > John --
> > >
> > > I can't think of anything in the extension mechanism that would make
> > > this happen.  If null is returned from an extension element, nothing
> > > happens.  If returned from an extension function, it just turns into an
> > > XNull.  If you can't figure it out, please post what I would need to
> > > recreate the situation.
> > >
> > > Thanks,
> > > Gary
> > >
> > > John Gentilin wrote:
> > > >
> > > > If my extension returns null, the transformation seems to
> > > > complete as expected but Process never seems to terminate,
> > > > like some background thread is just keeping the program
> > > > hung up.
> >
> >   ------------------------------------------------------------------------
> > <?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/" />
> >     <xsl:value-of select="sql:close($db)"/>
> >
> > </xsl:template>
> >
> > </xsl:stylesheet>

Reply via email to