You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2004/02/02 11:26:59 UTC

DO NOT REPLY [Bug 26595] New: - SQL Extension - ResultSet is not returning iteration of values

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26595>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26595

SQL Extension - ResultSet is not returning iteration of values

           Summary: SQL Extension - ResultSet is not returning iteration of
                    values
           Product: XalanJ2
           Version: 2.0.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xalan.extensions
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: juraj.lenharcik@t-systems.com


Running a SQL-statement via the SQL-extension is not returning all values of 
the table. For example the table looks like this:

1 | test1
2 | test2
3 | test3

Is returning the following output from the XSL:
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test3

If you create a variable with the same structure you get with the same XSL:
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 1
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test1
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 2
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test2
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; 3
file:/C:/temp/XSLSQL/bin/dbtest.xsl; Zeilennummer148; Spaltennummer15; test3


Here is the XSL code:

<?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"
                
                xmlns:xalan="http://xml.apache.org/xalan"
                   
                exclude-result-prefixes="xalan"                
                
                >



<xsl:output method="html" indent="yes"/>

<!-- parameter setting to connect to DB2
<xsl:param name="driver" select="'COM.ibm.db2.jdbc.app.DB2Driver'"/>

<xsl:param name="datasource" select="'jdbc:db2:sample'"/>
-->

<!-- parameter setting to connect to MySQL -->

<xsl:param name="driver" select="'com.mysql.jdbc.Driver'"/>

<xsl:param name="datasource" select="'jdbc:mySQL://localhost/test'"/>

<xsl:param name="query" select="'SELECT * FROM testtabelle'"/>

<xsl:param name="username" select="'root'"/>

<xsl:param name="passwd" select="''"/>

<xsl:variable name="testt">
	<row-set>
		<row>
			<col>1</col>
			<col>test1</col>
		</row>
		<row>
			<col>2</col>
			<col>test2</col>
		</row>
		<row>
			<col>3</col>
			<col>test3</col>
		</row>
	</row-set>	
</xsl:variable>


<xsl:template match="/">

    

    <xsl:variable name="db" select="sql:new()"/>

    

    <!-- Connect to the database with minimal error detection -->

		<xsl:if test="not(sql:connect($db, $driver, $datasource, 
$username, $passwd))" >

    	<xsl:message>Error Connecting to the Database</xsl:message>

      <xsl:copy-of select="sql:getError($db)/ext-error" />

    </xsl:if>

    

    <HTML>

      <HEAD>

        <TITLE>List of products</TITLE>

      </HEAD>

      <BODY>

        <TABLE border="1">

          <xsl:variable name="table" select='sql:query($db, $query)'/>

          <xsl:if test="not($table)" >

          	<xsl:message>Error in Query</xsl:message>

            <xsl:copy-of select="sql:getError($db)/ext-error" />

          </xsl:if>

          

          <TR>

             <xsl:for-each select="$table/sql/metadata/column-header">

               <xsl:message><xsl:value-of select="@column-label"/></xsl:message>

             </xsl:for-each>

          </TR>

          <xsl:apply-templates select="$table/sql/row-set"/> 
		  <xsl:variable name="testtabelle2" select="xalan:nodeset
($testt)"/>
<!--          <xsl:apply-templates select="$testtabelle2/row-set"/>-->

        </TABLE>

      </BODY>

    </HTML>

    <xsl:value-of select="sql:close($db)"/>

</xsl:template>

<xsl:template match="row-set">
  <xsl:for-each select="./row">
  	<xsl:apply-templates select="."/>
  </xsl:for-each>		
</xsl:template>

<xsl:template match="row">
  <xsl:apply-templates select="./col"/>
</xsl:template>

<xsl:template match="col">
	<xsl:message><xsl:value-of select="./text()"/></xsl:message>
</xsl:template>



</xsl:stylesheet>