Hi Christine, I have tried it, but it has no effect... With the variable it is running, but if the data is from db I get wrong data.
The table is correct: +-------+-------+ | index | name | +-------+-------+ | 1 | test1 | | 2 | test2 | | 3 | test3 | +-------+-------+ Also the stylesheet: <?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="test"> <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)'/> <!-- 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: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($test)"/> <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:apply-templates select="row"/> </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> Juraj -----Ursprungliche Nachricht----- Von: Christine Li [mailto:[EMAIL PROTECTED] Gesendet: Montag, 2. Februar 2004 15:31 An: Lenharcik, Juraj Cc: [EMAIL PROTECTED] Betreff: Re: SQL extension is not returning the correct resultset??! Hi, Juraj It may related to bug 12337 @ http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12337 . It provides a workaround by adding a dummy template. If you twist your stylesheet a bit by changing <xsl:template match="row-set"> <xsl:for-each select="./row"> <xsl:apply-templates select="."/> </xsl:for-each> </xsl:template> To <xsl:template match="row-set"> <xsl:apply-templates select="row"/> </xsl:template> It should work. You can refer to the extension sample codes shipped with Xalan. Christine Li XSLT Development IBM Toronto Lab Tel: (905)413-2601 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] -systems.com To 02/02/2004 06:25 [EMAIL PROTECTED] AM cc Subject SQL extension is not returning the correct resultset??! Hello, I am using the SQl extension from xalan to retrieve some data form a database. After the connection if I iterate over the resultset I get still the same row. The interation index is correct. For example: Table: 1 | test1 2 | test2 3 | test3 I get: Zeilennummer148; Spaltennummer15; 3 Zeilennummer148; Spaltennummer15; test3 Zeilennummer148; Spaltennummer15; 3 Zeilennummer148; Spaltennummer15; test3 Zeilennummer148; Spaltennummer15; 3 Zeilennummer148; Spaltennummer15; test3 If I use the same code on a local created variable, with the same xml-strucure I get the correct values: Zeilennummer148; Spaltennummer15; 1 Zeilennummer148; Spaltennummer15; test1 Zeilennummer148; Spaltennummer15; 2 Zeilennummer148; Spaltennummer15; test2 Zeilennummer148; Spaltennummer15; 3 Zeilennummer148; Spaltennummer15; test3 Has someone the same effect? Juraj XSL: <?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)'/> <!-- 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: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>
